def _upload_file(self, endpoint, path, form_data=None):
multipart_data = {}
if form_data is not None:
for key, value in form_data.iteritems():
multipart_data[key] = (None, value)
with open(path, 'rb') as src_file:
multipart_data['file'] = src_file
response = requests.request('POST',
url='{}/{}'.format(self._api_root, endpoint),
headers={'Accept': 'application/json'},
auth=(self._login + '/token', self._token),
files=multipart_data)
if response.status_code in (httplib.NO_CONTENT, httplib.CREATED):
return response.json()
raise APIError(response.text, response.status_code)
zendesk_localization.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录