multipart/form-data in an HTTP client

Nelson Minar nelson at monkey.org
Wed Sep 1 10:52:33 EDT 2004


I'm writing some code to upload photos to Flickr. The Photo Upload API
requires documents be POSTed via a multipart/form-data request. I was
surprised to learn that Python 2.3's HTTP clients don't support this
form of POSTs. There is support in cgi.py, for servers.

There are some implementations of multipart/form-data on ASPN:
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306
urllib2_file seems to meet my needs, but I'm not wild about how it's
implemented. Is there some other recommended way to do
multipart/form-data uploads with HTTP in Python?


References:
  http://www.flickr.com/services/api/
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306
  http://www.faqs.org/rfcs/rfc1867.html



More information about the Python-list mailing list