Re: Large file uploads

[email protected]
Newsgroups gmane.comp.python.twisted.web
Message-ID <20100724035006.27251.1144516852.divmod.xquotient.144@localhost.localdomain>
On 23 Jul, 08:34 pm, [email protected] wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Am 16.07.2010 17:33, schrieb [email protected]:
>>
>>You can override `Request.gotLength` to inspect the request and select
>>an appropriate destination for the request body.
>>
>>You can convince Site to use your custom request by setting it as the
>>`requestFactory` attribute.
>>
>>Jean-Paul
>
>Hi,
>
>thanks for your reply. In meantime I tried cherrypy, which does its job
>very good but has some flaws compared to my twisted applications when 
>it
>comes to performance and resource usage. So I'm still interested in
>solving my problem by using twisted.
>The problem is as follows: The file which shall be uploaded is sent via
>a HTML form (encoded as multipart/form-data), and I'd like to use
>Python's FieldStorage to parse the request body because it handles the
>file matters very well. You can tell cherrypy, that for a certain
>request uri cherrypy should not parse the request body but instead pass
>it on unparsed to the handler method.
>Is there a simple way of configuring twisted.web in this way to?
>So that e.g. if request uri /do-upload-form is issued, twisted.web does
>not try to parse the request body on its own and generate the args dict
>to pass on to the render_POST method, but instead uses FieldStorage (or
>better: my own subclass of FieldStorage, which employs a NamedTempFile
>instead of an anonymous tempfile, which allows me to simply rename it
>after it has passed some sanity checks) for parsing the body?

This will be easier once #288 is resolved.  Until then, you just have to 
hack around with the Request to change the behavior at a very low level.

Jean-Paul
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.