classification
Title: multipart/form-data encoding
Type: feature request Stage: test needed
Components: Library (Lib) Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Support iterable bodies in httplib
View: 3243
Superseder:
Assigned To: barry Nosy List: ajaksu2, alexz, barry, catlee, fsteinel, gotgenes, guettli, jnoller, orsenthil, r.david.murray, shazow, tamentis (12)
Priority: normal Keywords easy

Created on 2008-06-30 18:04 by catlee, last changed 2010-01-11 03:03 by r.david.murray.

Messages (7)
msg69015 - (view) Author: Chris AtLee (catlee) Date: 2008-06-30 18:04
The standard library should provide a way to encode data using the
standard multipart/form-data encoding.

This encoding is required to support file uploads via HTTP POST (or PUT)
requests.

Ideally file data could be streamed to the remote server if httplib
supported iterable request bodies (see issue #3243).

Mailing list thread:
http://mail.python.org/pipermail/python-dev/2008-June/080783.html
msg76356 - (view) Author: Florian Steinel (fsteinel) Date: 2008-11-24 19:38
see http://code.activestate.com/recipes/146306/ for a user contributed
implementation.
msg76357 - (view) Author: Chris AtLee (catlee) Date: 2008-11-24 19:54
I also wrote some software to handle this:
http://atlee.ca/software/poster/poster.encode.html

The reason I wrote this is to avoid having the load the entire file into
memory before posting the request.

This, along with Issue #3243, would allow streaming uploads of files via
HTTP POST.
msg81498 - (view) Author: Daniel Diniz (ajaksu2) Date: 2009-02-09 21:47
So, what is the best way to go about this (beyond docs and tests)? Beat
the linked recipe into a patch, adapt Chris' implementation?
msg93657 - (view) Author: Andrey Petrov (shazow) Date: 2009-10-06 18:35
Once upon a time I wrote a library that did some of this among other things:

http://code.google.com/p/urllib3/

Or specifically:
http://code.google.com/p/urllib3/source/browse/trunk/urllib3/filepost.py

The code was borrowed from some of the recipes mentioned, but cleaned up
and adjusted a bit. Feel free to use it or borrow from it in any way you
like.
msg93666 - (view) Author: Jesse Noller (jnoller) Date: 2009-10-06 21:53
This request really does need a patch+tests+doc changes - I don't know if 
anyone with +commit has the time to distill the various implementations 
and generate something.
msg97571 - (view) Author: R. David Murray (r.david.murray) Date: 2010-01-11 03:03
Daniel suggested marking this as superseding issue 727898, and I agree.  But I want to note that in that issue Barry suggested that it was possible services from the email package could be useful in building this support, and that there might be a better place for it to live than urllib.
History
Date User Action Args
2010-01-11 03:04:07r.david.murraylinkissue727898 superseder
2010-01-11 03:03:26r.david.murraysetnosy: + r.david.murray
messages: + msg97571
2009-11-03 11:58:42guettlisetnosy: + guettli
2009-10-06 21:53:20jnollersetnosy: + jnoller
messages: + msg93666
2009-10-06 18:35:25shazowsetnosy: + shazow
messages: + msg93657
2009-08-12 18:17:55tamentissetnosy: + tamentis
2009-07-19 18:40:04alexzsetnosy: + alexz
2009-05-04 15:45:25barrysetassignee: barry

nosy: + barry
2009-04-22 18:48:42ajaksu2setpriority: normal
2009-02-12 17:47:25ajaksu2setkeywords: + easy
nosy: + orsenthil
dependencies: + Support iterable bodies in httplib
stage: test needed
2009-02-09 21:47:09ajaksu2setnosy: + ajaksu2
messages: + msg81498
2009-01-07 18:29:50gotgenessetnosy: + gotgenes
2008-11-24 19:54:47catleesetmessages: + msg76357
2008-11-24 19:38:54fsteinelsetnosy: + fsteinel
messages: + msg76356
2008-06-30 18:04:19catleecreate