En Wed, 27 Apr 2011 11:14:54 -0300, Torsten Bronger <bron...@physik.rwth-aachen.de> escribió:

Hallöchen!

I'm skimming through the various recipies for uploading a file via
HTTP.  Unfortunately, all of them are awkward but also rather old.
(See for example
http://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script)

In my module, I do my HTTP request like this:

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
opener.open(url, urllib.urlencode(data, doseq=True))

Well, and now I'd also like to include a file upload to the POST
data.  The solution should use urllib2, otherwise I'd have to change
most of my existing code.

If you now say "Torsten, unfortunately it *is* so complicated" I'll
jump through the hoops, but I'd love to hear that with Python 2.6.5
there's an easier way.  ;-)

This particular battery isn't included (yet - see http://bugs.python.org/issue3244)
but this little library may help:
https://bitbucket.org/chrisatlee/poster

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to