How do I set the mime type for files (for one file, not for the form) uploaded with Python Requests?
import requests
requests.post('http://test.com/upload', files={'data':'123'})
You can use tuples and lists to pass additional options for posted files. http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
{file_field: (name, content, content_type, additional_file_headers)}
So
import requests
requests.post('http://test.com/upload', files={'data': ('readme.txt', 'Readme file content or pointer', 'text/plain')})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With