The r
variable in the examples contains the full binary data of whatever file you're sending.
url = 'http://your_url'
files = {'file': open('myfile.test', 'rb')}
r = requests.post(url, files=files)
url = 'http://httpbin.org/post'
files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}
r = requests.post(url, files=files)
url = 'http://httpbin.org/post'
files = {'file': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')}
r = requests.post(url, files=files)
r.text
Parameters | Function |
---|---|
file | JSON List of paths to the files. |
content_type | MIME Types |
headers | HTTP Headers |