# Limit file download size

**URL:** <https://www.ruby-forum.com/t/limit-file-download-size/196412>\
**Category:** Ruby\
**Created:** [July 29, 2007, 10:36pm UTC](https://www.ruby-forum.com/t/limit-file-download-size/196412 "2007-07-29T22:36:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@andreim](https://www.ruby-forum.com/u/andreim)\
**Post date:** [July 29, 2007, 10:36pm UTC](https://www.ruby-forum.com/t/limit-file-download-size/196412/1 "2007-07-29T22:36:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andreim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@andreim](https://www.ruby-forum.com/u/andreim)\
**Post date:** [July 30, 2007, 4:28am UTC](https://www.ruby-forum.com/t/limit-file-download-size/196412/2 "2007-07-30T04:28:59Z")

</div>

On 7/29/07, andreim [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi, I’m writing a ruby on rails application

[http://groups.google.com/group/rubyonrails-talk](http://groups.google.com/group/rubyonrails-talk)

---

<div class="post-metadata">

**Author:** ![andreim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@andreim](https://www.ruby-forum.com/u/andreim)\
**Post date:** [August 1, 2007, 9:08am UTC](https://www.ruby-forum.com/t/limit-file-download-size/196412/3 "2007-08-01T09:08:34Z")

</div>

On 2007-07-31 17:05:24 +0900 (Tue, Jul), Shai R. wrote:

> anyone know how to notify the user, client side, that the upload is too  
> big??

I recall there was some magic hidden field - google  
for ‘upload form max\_file\_size’

Other than that, you can always put:

Please, don't upload files bigger than X kb

:-)

---

<div class="post-metadata">

**Author:** ![andreim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@andreim](https://www.ruby-forum.com/u/andreim)\
**Post date:** [August 1, 2007, 9:55pm UTC](https://www.ruby-forum.com/t/limit-file-download-size/196412/4 "2007-08-01T21:55:22Z")

</div>

On 7/31/07, Shai R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> anyone know how to notify the user, client side, that the upload is too  
> big??

[http://groups.google.com/group/rubyonrails-talk](http://groups.google.com/group/rubyonrails-talk)

---

<div class="post-metadata">

**Author:** ![andreim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@andreim](https://www.ruby-forum.com/u/andreim)\
**Post date:** [July 31, 2007, 10:05am UTC](https://www.ruby-forum.com/t/limit-file-download-size/196412/5 "2007-07-31T10:05:25Z")

</div>

anyone know how to notify the user, client side, that the upload is too  
big??
