【发布时间】:2016-10-07 19:10:25
【问题描述】:
我正在尝试使用 Python 的请求复制 curl PUT -F "file=@someFile" 的使用。
我需要使用的 Content-Type 是:multipart/form-data
我尝试了不同的变体,例如:
r = requests.put(url, headers=headers, files={'file': (full_filename, open(full_filename, 'rb'), content_type)}, verify=False, stream=True)
r = requests.put(url, headers=headers, data={'file': (full_filename, open(full_filename, 'rb'), content_type)}, verify=False, stream=True)
r = requests.put(url, headers=headers, params={'file': (full_filename, open(full_filename, 'rb'), content_type)}, verify=False, stream=True)
在我尝试的所有方法中,我的标题中都有'Content-Type': 'multipart/form-data'。
但对于上述所有情况,我得到400 作为回复。
我看到一些关于 stackoverflow 的问题,但没有一个答案能回答我的问题,所以我要开一个新的。
【问题讨论】:
标签: python curl python-requests multipartform-data put