Search code examples
pythonpython-3.x

How to remove content-disposition from upload file


I have tried other solution get from SO to remove and upload the file without content-header

but still it wont work

My code is below

def upload_file(fpath):
     headers = {
         'Api-Key': sys.argv[16]
     }
     files = {'file': open(fpath, 'r').read()}
     response = requests.request("PUT", +"https://abcd.om/inventory/"+str(sys.argv[3]), headers=headers, files=files)
 

But still it get

--9bcf1c0247af690b91cad8f301346f2e
Content-Disposition: form-data; name="file"; filename="file"

in end

-9bcf1c0247af690b91cad8f301346f2e--

Any help would


Solution

  • I have solved it by below

     response = requests.put(url, headers=headers, data=open(fpath,'rb').read())