Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CURL -T (--upload-file equivalent) in Python Requests

I am looking for an equivalent of curl:

curl http://my_url:8080 -H "Content-type: application/csv" -T test.csv

I am especially looking for an alternative to -T filepath.

I've read the request documentation and all the easy convert method like https://curl.trillworks.com/ or uncurl doesn't convert the parameter -T.

like image 965
Thomas Jalabert Avatar asked Mar 05 '23 04:03

Thomas Jalabert


1 Answers

I found the answer by calling my curl request with verbose.

Use request.put() with the content of your file in the parameter data.

 response = requests.put(url, headers=headers, data=open(path_file,'r').read())    
like image 181
Thomas Jalabert Avatar answered Mar 27 '23 00:03

Thomas Jalabert