Welcome Guest | Login

How to limit upload file size?

Hi,

I've setup a webpage on my Rails app where users can upload a file. I'd like to limit the size of these uploads. I know Apache has the LimitRequestBody directive which can be put in .htaccess but I'm wondering how can this be done for the Rails app (or maybe for fastcgi?)

thanks,
-fred

2007-01-07 07:11 AM

You can probably use file_column and set up a custom error_log message if the file size is too big.  I'm not exactly sure what the Ruby commands are for doing this, but I'm pretty sure you can pull it off in your model with only a few lines of code.  You'll have to look into custom error messages and how to check the size of the temporally uploaded file...let me know if you make any progress on this, sorry I couldn't be more helpful.  

~William

2007-01-07 11:42 AM

thanks for pointing out the file_column (did not know about it...).

The good thing with the Apache directive is that it is really at the request level (i.e while the file is being uploaded), I don't think the file_column will solve this. But maybe I don't need to go this further, I will inform the user uploads are limited in size to XX MB, the user uploads the file and then I "manually" check if it's under XX MB or not, I would have preferred to not have to bother with this but well, it will be enough for now.

2007-01-07 11:55 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up.