Rajarshi Das
Rajarshi Das

Reputation: 12340

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

Upvotes: 3

Views: 1459

Answers (2)

user28741964
user28741964

Reputation: 1

I encountered this issue with Azure's blob storage, trying to upload an audio file. the fix was to include the content-type, and use the 'data' key in the put request

resp = requests.put(url, data=open(filename,'rb').read(), headers={'x-ms-blob-type': 'BlockBlob','Content-Type': 'audio/m4a'})

note that no translation was needed for the audio file, and it can just be put as a filestream

Upvotes: 0

Rajarshi Das
Rajarshi Das

Reputation: 12340

I have solved it by below

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

Upvotes: 2

Related Questions