I am trying to upload a file to django python server through python client.
I tried this -
import requests
url = 'http://wings.spectrumserver/sdm/lists'
files = {'file': open('file.ext', 'rb')}
r = requests.post(url, files=files)
but somehow it is not working. No error but no output/upload as well
I am successfully upload files by browser and command line.
curl -i --form docfile=@localfilename http://wings.spectrumserver/sdm/lists
Please suggest what to do ??
I do not know much about curl and python but maybe someone could suggest something which is replica of this curl command in pycurl
as it is already working with curl.
Please refer here for more details about question -
I think the problem here is the name of file element. It should be docfile
. In curl example you have passed that as docfile
but in the python script you left it as file
.
Alter this line:
files = {'file': open('file.ext', 'rb')}
to this:
files = {'docfile': open('file.ext', 'rb')}