I want to set the name of a file I'm uploading via requests module.
files = {'filename': open('myfileXXAAAZZZD','rb')}
r = requests.post("http://127.0.0.1:5000/", files=files)
It is possible with curl but don't know if requests support's this:
As stated in the docs, the values of the files
dict can be tuples with filename and content as the first of possibly more elements. So something like
files = {'fieldname': ('filename.any', open('myfileXXAAAZZZD','rb').read())}
should do the trick.
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