title: How do you restrict large file uploads in wsgi?
body: <p>I'm trying to get an understanding of the best way of handling file uploads <strong>safely</strong> in a wsgi app. It seems a lot of solutions involve using FieldStorage from the cgi module to parse form data. From what I understand about FieldStorage it performs a bit of 'magic' behind the scenes by streaming data into a tempfile.</p>
  
  <p>What I'm not 100% clear on is how to restrict a request containing a file greater than a specified amount (say 10MB). If someone uploads a file which is several GB in size you obviously want to block the request before it chews through your server's disk space right?</p>
  
  <p>What is the best way to restrict file uploads in a wsgi application?</p>