[Mongrel] Upload progress and limiting file sizes
Zed Shaw
zedshaw at zedshaw.com
Thu Sep 7 19:28:35 EDT 2006
On Thu, 2006-09-07 at 22:01 +0100, Mike Evans wrote:
> Thanks to all concerned with the implementation of the Upload
> Progress plugin, it works really well.
>
> I want to limit the size of files to be uploaded to say 10Mb. Is
> there any way for Mongrel to 'refuse' to upload files over a certain
> size and then pass an error onto Rails in order to display feedback
> to the user? I don't really want to have to upload the whole file and
> then delete it if it's over the limit.
>
> What about the possibility of a user cancelling an upload that's
> currently in progress?
>
> Apologies if these questions are naive, but I've always taken web
> servers for granted so am very much a newb.
Nope, good question. Simples way is to write a very little handler you
put in front that simple checks the CONTENT_LENGTH and then redirects.
Then put it in front in a -S mongrel.conf:
uri "/", :handler => AhabTheMobyFileKiller.new(:path =>
"/file/upload"), :in_front => true
Or, you could modify the stock upload handler to take another parameter.
Kick back the patch if you do, other folks will probably want that.
--
Zed A. Shaw
http://www.zedshaw.com/
http://mongrel.rubyforge.org/
http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
More information about the Mongrel-users
mailing list