You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jim the Standing Bear <st...@gmail.com> on 2009/10/05 22:46:30 UTC

Re: is there an absolute max file upload size? - my findings

thanks for the response Stephen, and you are right on the spot.  After
some experiments, here is what I found out about the peculiarity of
file upload:

1. the servlet spec indeed defines a 32-bit value for maximum file
sizes, however, myfaces seems to interpret it as an unsigned 32-bit,
so for maxFileUploadSize in web.xml, it could use the following
values:

4095m, or 4194303k

which in principle allow files just slightly short of 4GB.

however, the straight-forward 2^32-1 expressed as bytes (4294967295)
does not work - it crashes myfaces and wouldn't even let myfaces app
load.

2. these numbers wrap.  that is, if you used 4g, or 4096m, or
4194304k, they wrap around to be 0, and you won't be able to submit
anything because the file upload input has some additional state data
and they will exceed the 0-size limit.  odd, isn't it?


3. but in practice, I believe the entire form submitted (the encoded
file contents and other form data) can only be under 2GB.  It may be
the browser, or maybe browser + container.  Not sure.   I managed to
upload a file with 8-letter name and a 3-letter extension and
2147481170 bytes in size.  but then after a restart of the server,
this size stopped working and I couldn't quite put my finger on what
the difference there was between now and then...

In case someone wonders about the same, I hope this will serve as a
good reference

-- Jim




On Sat, Oct 3, 2009 at 2:37 AM, Stephen Connolly
<st...@gmail.com> wrote:
> Be aware that the servlet spec defines the filesize as an signed 32 bit*, so
> that unless code is written correctly, there will always be a hard limit of
> 2GB on upload with size information in advance... since one DOS attack is to
> upload a file of unlimited size (thereby filling your storage) most good
> upload components will refuse an unbounded upload (which is what anything
> over 2GB will look like as a result of the servlet spec)
>
> Not sure if this applies to your case, but an FYI for you anyway
>
> -Stephen
>
> * public int ServletRequest.getContentLength() - returns the length (in
> bytes) of the content being sent by input stream or -1 if the length is not
> known (or if the length is greater than 2GB)
>
> 2009/10/3 Jim the Standing Bear <st...@gmail.com>
>>
>> thank you for the response, Anuj.  However, I am not entirely certain
>> if this property applies.  For one thing, I am only using tomahawk,
>> not trinidad, and also I was able to upload files in hundred-megabyte
>> range, just not in GB, so if this property was the cause, I wouldn't
>> even be able to get these files in.
>>
>> I even enabled debug log on myfaces objects, but it didn't log
>> anything at all, no exceptions.
>>
>> Any other possibilities?
>>
>> On Fri, Oct 2, 2009 at 5:48 PM, Patel, Anuj <ap...@medicalert.org> wrote:
>> > Hey Jim,
>> > There is a property org.apache.myfaces.trinidad.UPLOAD_MAX_DISK_SPACE
>> > that you need to specify in your web.xml.  This is the max allowable
>> > disk space for your file.  If you go beyond that, it will throw an
>> > exception from its filter.  The default is 5120000 (5000 KB).
>> >
>> > Anuj Patel
>> > Software Engineer
>> > MedicAlert Foundation
>> > 209 669 2467
>> > www.medicalert.org
>> > Protect our planet. Consider the environment before you print this
>> > email.
>> >
>> >
>> >
>> > -----Original Message-----
>> > From: Jim the Standing Bear [mailto:standingbear@gmail.com]
>> > Sent: Friday, October 02, 2009 2:15 PM
>> > To: MyFaces Discussion
>> > Subject: is there an absolute max file upload size?
>> >
>> > Hello,
>> >
>> > I am wondering if there is an absolute max file upload size that if
>> > the file I want to upload exceeds that size, it won't work even if the
>> > maxFileUploadSize in web.xml is set much higher?  If so, what is it?
>> >
>> > Because I am trying to upload a 3GB file using the inputFileUpload
>> > control, and web.xml has set the maxFileUploadSize to 5g.  But nothing
>> > happens after I clicked the submit button - it didn't even attempt to
>> > upload the file.  Normally if I am trying to upload a file that
>> > exceeds the max size, it will take some time to suck the bitstream to
>> > the server and then rerender the page; but in my situation, it seemed
>> > to simply give up without even sucking the bitstream first.
>> >
>> > Any help would be appreciated.
>> >
>> > -- Jim
>> >
>>
>>
>>
>> --
>> --------------------------------------
>> Standing Bear Has Spoken
>> --------------------------------------
>
>



-- 
--------------------------------------
Standing Bear Has Spoken
--------------------------------------