My problem is a general problem. I want to perform data sending (big binary container file) to a uC which works with a prepared html sending script written in C#.
C# Code:
WebClient client = new WebClient();
client.UploadFileAsync(uri, "POST", "C:\\Users\\user1\\file\\to\\the\\firmware\\fw-container.efc");
Here the problem is that upload does not succeed (doesn't even start uploading in Python) although the script runs through. The problem should be in the code, because other way the upload could be completed Python code:
import pycurl
from cStringIO import StringIO
import urllib2
import simplejson as json
url = 'http://eData/pvi?rName=FirmwareUpload'
req = urllib2.Request(url)
req.add_header('Content-Type','application/json')
c = pycurl.Curl()
c.setopt(c.POST, 1)
c.setopt(c.URL, url)
c.setopt(c.CONNECTTIMEOUT,0)
c.setopt(c.TIMEOUT, 0)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.MAXREDIRS, 5)
c.setopt(pycurl.NOSIGNAL, 1)
c.setopt(c.HTTPPOST, [("file1", (c.FORM_FILE,"C:\\Users\\user1\\file\\to\\the\\firmware\\fw-container.efc""))])
c.perform()
print "Upload was successful!"
print "Tx JSON:"
print "POST resource"
res = urllib2.urlopen(req)
print "Response:"
str_0 = res.read()
print str_0
c.close()
The error message looks like this at line of c.perform():
PYCURL ERROR 6 - "Couldn't resolve host 'eData'"
I do not know how could I make upload work even if I use different python library. I have found the following options for library using: urllib2 sending with multiple handling data way (never tried, do not know how to do) requests library (does not work with 2.5 python) poster library (seems impossible to install eggs for python 2.5) and PyCurl (I went to this direction)
Please do a suggestion no matter how small this is or related to other library solutions. Thank you!