multipart/form-data in an HTTP client
Jeff Shannon
jeff at ccvcorp.com
Wed Sep 1 14:59:42 EDT 2004
Nelson Minar wrote:
>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?
>
>
I've been using something closely modelled on that Cookbook recipe,
without any real problems. (I've updated it to use HTTP[S]Connection()
and return the response object, and in my case I'm connecting to an
HTTPS server, but these are trivial modifications.)
I, too, was surprised that the existing Python libraries don't directly
support multipart/form-data already, and I hope that this gets added in
soon.
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list