Forum: Ruby on Rails how to limit file download size?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
andreim (Guest)
on 2007-07-30 00:33
(Received via mailing list)
Hi, I'm writing a ruby on rails application that allows the user to
submit a link of a file which my app will then download.
Right now my app blindly downloads the file (which is 1-2mb on
average)
I'm worried about pranksters who would intentionally submit links to
30gb files.
Is there a way to set the maximum size of a file that I'm downloading?

One possible solution is to parse the content-length field of the file
header. But the server need not send this field along with the file.

I just want my application to stop downloading when the file gets to a
certain size (say 2mb) and alert the user that the file they submitted
is too big.

Thanks!

--Andrei
Procrastinx (Guest)
on 2007-07-30 17:16
(Received via mailing list)
On Jul 30, 1:32 am, andreim <removed_email_address@domain.invalid> wrote:
>
> I just want my application to stop downloading when the file gets to a
> certain size (say 2mb) and alert the user that the file they submitted
> is too big.
>
This is a job of the web server. For apache look up the
LimitRequestBody configuration directive - it  will allow you to
specify  the maximum allowed Content-Length for requests to your
server.

--
P
This topic is locked and can not be replied to.