title: Rails - set POST request limit (file upload)
body: <p>I am building a file uploader for Rails, using <a href="https://github.com/jnicklas/carrierwave" rel="nofollow">CarrierWave</a>. I am pretty happy about it's API, except that I don't seem to be able to cut file uploads that exceed a limit on the fly.</p>
  
  <p>I found <a href="https://github.com/jnicklas/carrierwave/wiki/How-to%3a-Validate-attachment-file-size" rel="nofollow">this plugin</a> for validation, but the problem is that it happens <strong>after</strong> the upload is completed. It is completely unacceptable in my case, <em>as any user could take the site down by uploading a huge file</em>.</p>
  
  <p>So, I figure that the way would be to use some Rack configuration or middleware that will limit POST body size as it receives. I am hosting on Heroku, as context.</p>
  
  <p>*I am aware of <a href="https://github.com/dwilkie/carrierwave_direct" rel="nofollow">https://github.com/dwilkie/carrierwave_direct</a> but it doesn't solve my issue as I have to resize first and discard the original large image.</p>