【发布时间】:2016-11-11 05:29:38
【问题描述】:
我的 API:
class FileView(APIView):
parser_classes = (MultiPartParser,)
def post(self, request):
do something with request.FILES.dict().iteritems()
我的requests 文件:
try:
headers = {
'content-type': "multipart/form-data",
'authorization': "Basic ZXNlbnRpcmVcYdddddddddddddd",
'cache-control': "no-cache",
}
myfile = {"file": ("filexxx", open(filepath, "rb"))}
response = requests.request("POST", verify=False, url=url, data=myfile, headers=headers)
print(response.text)
except Exception as e:
print "Exception:", e
错误:
“多部分表单解析错误 - 多部分中的边界无效:无”
发布文件的正确方法是什么?谢谢
请求。版本 '2.10.0'
【问题讨论】:
标签: python django-rest-framework python-requests