def uploadMaterial(self, ad: Ad, params: dict) -> ReqResult:
reqResult = self.getFielToken()
if not reqResult.succ:
return reqResult
files = {
"file": open(ad.materialLocalPath, "rb")
}
data = {
'file_token': reqResult.result.get('file_token'),
'asset_name': ad.planName,
}
method, url = self.getMethodUrl('uploadMaterial', None)
reqResult = request.doReq(method, url, None, self.fielBuildHeader(), files, self.buildReqResult, data)
def fielBuildHeader(self):
access_token = self.getAccessTokenTwo(self.account_id, self.product, self.channel)
return {'Authorization': 'Bearer ' + access_token, 'Accept': 'application/json'}
网友评论