<div dir="ltr"><div>Pranav</div><div><br></div>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.<div><br></div><div>
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.</div>
<div><br></div><div>There is also not currently a way to limit either the size of the request, or the size of individual files in the request.</div><div><br></div><div>Assuming that you need a solution and don't want to work on implementing this in Twisted, I would suggest using nginx as a reverse proxy in front of Twisted, with the "Upload" module that can be found on the Addons page on nginx's wiki. This module will place any uploaded files into files on the disk, and include regular request parameters to tell your Twisted server where these files are. It is also capable of putting limits in place on the size of uploaded files.</div>
<div><br></div><div>Cameron</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 17 July 2013 01:58, Pranav Bhardwaj <span dir="ltr"><<a href="mailto:pranavb85@gmail.com" target="_blank">pranavb85@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hey<br><br></div>I have a script to be able to upload logs to a twisted web server. <br><br>
I have the following requirements:<br><br>1) to be able to limit the size of the upload to 10MB. <br>
2)  to NOT store file in memory during the request.<br><br></div><div>Does twisted.web provide these functionality?<br><br>Any inputs on these would be welcome!<br><br><br></div><div><br></div>Here is the <b>server part</b> os the script:<br>

<br>        try:<br>            oStream = open(filename, 'wb')<br>            oStream.write(request.args['fname'][0])<br>            outputStream.close()<br><br>        except:<br></div>            # handle exception<br>

<div><br><br></div><div>a test <b>client script:</b><br></div><div><br>

<table style="letter-spacing:normal;text-indent:0px;text-transform:none;word-spacing:0px"><tbody><tr><td><br></td><td><span><!DOCTYPE html></span></td></tr><tr><td><br></td><td>
<span><html></span></td></tr><tr><td><br></td><td>    <span><form <span>action</span>="<span><a href="https://serverUrl" target="_blank">https://serverUrl</a></span>"</span></td>
</tr><tr><td><br></td><td>            <span>enctype</span>="<span>multipart/form-data</span>"</td></tr><tr><td><br></td><td>            <span>method</span>="<span>post</span>"></td>
</tr><tr><td><br></td><td>        <span><div <span>class</span>="<span>row</span>"></span></td></tr><tr><td><br></td><td>           <span><label <span>for</span>="<span>fileUploadToServer</span>"></span>Select file<span></label></span><span><br /></span></td>

</tr><tr><td><br></td><td>           fname : <span><input <span>type</span>="<span>file</span>" <span>name</span>="<span>fname</span>" /></span></td>
</tr><tr><td><br></td><td>           <span><input <span>type</span>="<span>submit</span>" <span>value</span>="<span>submit</span>"></span></td>
</tr><tr><td><br></td><td>          <span></div></span></td></tr><tr><td><br></td><td>    <span></form></span></td></tr><tr><td><br></td><td><span></html></span></td>
</tr></tbody></table>

<br></div></div>
<br>_______________________________________________<br>
Twisted-web mailing list<br>
<a href="mailto:Twisted-web@twistedmatrix.com">Twisted-web@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
<br></blockquote></div><br></div>