Rails - set POST request limit (file upload)
Posted
by
Fabiano PS
on Stack Overflow
See other posts from Stack Overflow
or by Fabiano PS
Published on 2012-11-10T04:55:04Z
Indexed on
2012/11/10
4:59 UTC
Read the original article
Hit count: 117
I am building a file uploader for Rails, using CarrierWave. 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.
I found this plugin for validation, but the problem is that it happens after the upload is completed. It is completely unacceptable in my case, as any user could take the site down by uploading a huge file.
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.
*I am aware of https://github.com/dwilkie/carrierwave_direct but it doesn't solve my issue as I have to resize first and discard the original large image.
© Stack Overflow or respective owner