[Twisted-web] twisted.web : limiting file size during upload (using python)

Glyph glyph at twistedmatrix.com
Thu Jul 18 11:12:44 MDT 2013


On Jul 16, 2013, at 6:55 PM, Shell <cam.turn at gmail.com> wrote:

> I believe, assuming that this hasn't been worked on last time I looked at the code, that this is not currently possible. The code is about half way there.
> 
> The request processing function stores the request on the disk if it is over a certain size. However, once the request has been uploaded, a function from Python's cgi module is called to parse the data into request.params. Not only does this lose some information about file uploads (which can only be recovered by re-parsing the request), but it also loads all data into memory.

The trick to doing this with present twisted.web is to override the 'handleContentChunk' method of Request, rather than trying to catch the streaming-upload behavior in your Resource class.  Of course, the right thing to do is to help get <https://tm.tl/#288> fixed :).

-glyph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-web/attachments/20130718/c048a5c5/attachment.html>


More information about the Twisted-web mailing list