使用python的requests.post上传文件失败,(在网上看了些例子,post请求中需要带有files参数,但是我包含cookies之后,再增加files参数就报错了)
代码很简单
url = "https://"+ipaddress+":10111/rest/filetransfer/v1/file"
payload = "------WebKitFormBoundaryAnHMuAr1HTAVheZQ\r\nContent-Disposition: form-data; name=\"file\"; filename=\"D:\"+filename+".txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n----WebKitFormBoundaryAnHMuAr1HTAVheZQ--"
headers = {
'Content-type': "multipart/form-data; boundary=----WebKitFormBoundaryAnHMuAr1HTAVheZQ",
'cache-control': "no-cache",
'Postman-Token': "c6f68821-9dca-4913-99e2-b5d943bb1f6b"
}
response = requests.post(url, data=payload, cookies=cookies,headers=headers,verify=False)
payload中一些无关的参数我删掉了,方便各位前辈浏览,研究了两周,试了各种参数都不行,实在是很困惑
data中的Content-Type参数,我试过text/plain和application/octet-stream,都不行