shuNjj
shuNjj

Reputation: 47

Uploading a file via requests.put in python

I'm trying convert the following curl command to python code using requests module.

curl -v -X PUT -T video_file.mp4 https://my-app-domain.com

Already tried some ways like below but still not working.

with open(mp4_file_path, 'rb') as finput:
     response = requests.put('https://my-app-domain.com', data=finput)
       

Can someone please show me how to write it? Thank you in advance.

Upvotes: 1

Views: 1374

Answers (1)

VRComp
VRComp

Reputation: 131

According to the documentation here, data can accept "dictionary, list of tuples, bytes, or file-like object."

This should work:

with open(mp4_file_path, 'rb') as finput:
    response = requests.put('https://my-app-domain.com', data=finput.read())

Upvotes: 1

Related Questions