[Twisted-Python] reading multipart/form-data headers

Burak Arslan burak.arslan at arskom.com.tr
Thu Aug 11 09:55:35 MDT 2016


Hello All,

You can find a sample HTTP POST request using HTTP multipart/form-data
at the end of this message.

The server that handles this request is using twisted so I end up with a
Request object. Is there a way I can extract the file name
("image008.jpg") from this stream? I'm looking at the source of
cgi.parse_multipart() and it seems to be ignored.

Best regards Burak

PS:

POST /put HTTP/1.1
Host: localhost:7111
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------352471062160373366296932264
Content-Length: 382691

-----------------------------352471062160373366296932264
Content-Disposition: form-data; name="name"

a
-----------------------------352471062160373366296932264
Content-Disposition: form-data; name="version"

1
-----------------------------352471062160373366296932264
Content-Disposition: form-data; name="data"; filename="image008.jpg"
Content-Type: image/jpeg

(...)



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20160811/d4862ee9/attachment-0001.html>


More information about the Twisted-Python mailing list