zendesk_localization.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:zendesk-help-center-localization 作者: mykola-mokhnach 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号