You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Paul Rivera <pa...@gmail.com> on 2008/10/01 15:42:52 UTC

Re: fileupload sizelimitexception

Thanks for the info!

The hidden field that I need is located just before the end tag of my form.
Relocating it to some part in the beginning will be tough.  It will probably
be a last resort.

I'm wondering if:
  - I could still retrieve all my form fields even though I exceed the size
limit (including parameters before and after my file upload field)
  - even better if I can skip reading the file since its size is already not
acceptable and read only my field parameters from my web app.  Thus saving
some time by not waiting for the upload to complete.

Best Regards,
Paul Rivera

On Wed, Oct 1, 2008 at 12:56 AM, Martin Cooper <ma...@apache.org> wrote:

> On Tue, Sep 30, 2008 at 9:52 AM, Paul Rivera <pa...@gmail.com>
> wrote:
>
> > Hi!
> >
> > Thanks for the quick response.
> >
> > Yes, I have.  Sorry for the vagueness but let me clear things up a
> little.
> >
> > FileUploadBase.parseRequest() returns a List containing FileItem objects.
> > These FileItem objects can either be a file uploaded or a form field
> (these
> > form fields are what I need).
> >
> > In commons fileupload 1.0, FileUploadBase.parseRequest() throws an
> > Exception
> > if the maxSize is exceeded _before it even starts to read from the
> > MultipartStream.  Meaning, it will not even read the first form field.
> >
> > I've looked into fileupload 1.2.1 and the flow looks pretty much the
> same.
>
>
> If you use the streaming mode in 1.2, you should be able to capture the
> hidden field before you hit the max size limit.
>
> --
> Martin Cooper
>
>
> I was hoping I could make FileUploadBase.parseRequest() still return the
> > form fields (but exclude the data from the uploaded file) even in the
> case
> > when the maxSize is exceeded.
> >
> > Any ideas?
> >
> > Best Regards,
> > Paul Rivera
> >
> > On Tue, Sep 30, 2008 at 11:36 PM, F. Andy Seidl <
> > faseidl@myst-technology.com
> > > wrote:
> >
> > > Have you tried placing the hidden form field before the upload field in
> > the
> > > form?
> > >  -- fas
> > >
> > > -----Original Message-----
> > > From: Paul Rivera [mailto:paulrivera22@gmail.com]
> > > Sent: Tuesday, September 30, 2008 10:02 AM
> > > To: user@commons.apache.org
> > > Subject: fileupload sizelimitexception
> > >
> > > Hi!
> > >
> > > I'm using commons fileupload 1.0.  I'm in a situation wherein:
> > >
> > >  - if the user submits a file larger than my defined maxFileSize,
> > > FileUploadBase throws a SizeLimitExceededException which stops
> processing
> > > of
> > > the remaining parameters.
> > >  - i have a hidden field in my form that my web application needs to
> > > retrieve even in the case of an exceeded size limit.
> > >
> > > Does anyone have ideas on possible solutions here?
> > >
> > > I have not yet tried using the latest release,
> commons-fileupload-1.2.1.
> > > But skimming through the code, things look similar.  It looks like the
> > > exception will still be thrown before the rest of the parameters get
> > read.
> > >
> > > Best Regards,
> > > Paul Rivera
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: user-help@commons.apache.org
> > >
> > >
> >
>

Re: fileupload sizelimitexception

Posted by Paul Rivera <pa...@gmail.com>.
I've just upgraded to 1.2.1 to try out the streaming mode as described in:
http://commons.apache.org/fileupload/streaming.html

The sample from the webpage calls ServletFileUpload.getItemIterator().
This method calls FileUploadBase.getItemIterator() which throws the
SizeLimitExceededException.  So, if the requestSize is greater than sizeMax,
it throws SizeLimitExceededException and does not parse _any of the form
fields anymore.  (same problem)

Any other ideas before I attempt to implement my own FileUploadBase
subclass? :P

Best Regards,
Paul Rivera

On Wed, Oct 1, 2008 at 9:42 PM, Paul Rivera <pa...@gmail.com> wrote:

> Thanks for the info!
>
> The hidden field that I need is located just before the end tag of my
> form.  Relocating it to some part in the beginning will be tough.  It will
> probably be a last resort.
>
> I'm wondering if:
>   - I could still retrieve all my form fields even though I exceed the size
> limit (including parameters before and after my file upload field)
>   - even better if I can skip reading the file since its size is already
> not acceptable and read only my field parameters from my web app.  Thus
> saving some time by not waiting for the upload to complete.
>
> Best Regards,
> Paul Rivera
>
>
> On Wed, Oct 1, 2008 at 12:56 AM, Martin Cooper <ma...@apache.org> wrote:
>
>> On Tue, Sep 30, 2008 at 9:52 AM, Paul Rivera <pa...@gmail.com>
>> wrote:
>>
>> > Hi!
>> >
>> > Thanks for the quick response.
>> >
>> > Yes, I have.  Sorry for the vagueness but let me clear things up a
>> little.
>> >
>> > FileUploadBase.parseRequest() returns a List containing FileItem
>> objects.
>> > These FileItem objects can either be a file uploaded or a form field
>> (these
>> > form fields are what I need).
>> >
>> > In commons fileupload 1.0, FileUploadBase.parseRequest() throws an
>> > Exception
>> > if the maxSize is exceeded _before it even starts to read from the
>> > MultipartStream.  Meaning, it will not even read the first form field.
>> >
>> > I've looked into fileupload 1.2.1 and the flow looks pretty much the
>> same.
>>
>>
>> If you use the streaming mode in 1.2, you should be able to capture the
>> hidden field before you hit the max size limit.
>>
>> --
>> Martin Cooper
>>
>>
>> I was hoping I could make FileUploadBase.parseRequest() still return the
>> > form fields (but exclude the data from the uploaded file) even in the
>> case
>> > when the maxSize is exceeded.
>> >
>> > Any ideas?
>> >
>> > Best Regards,
>> > Paul Rivera
>> >
>> > On Tue, Sep 30, 2008 at 11:36 PM, F. Andy Seidl <
>> > faseidl@myst-technology.com
>> > > wrote:
>> >
>> > > Have you tried placing the hidden form field before the upload field
>> in
>> > the
>> > > form?
>> > >  -- fas
>> > >
>> > > -----Original Message-----
>> > > From: Paul Rivera [mailto:paulrivera22@gmail.com]
>> > > Sent: Tuesday, September 30, 2008 10:02 AM
>> > > To: user@commons.apache.org
>> > > Subject: fileupload sizelimitexception
>> > >
>> > > Hi!
>> > >
>> > > I'm using commons fileupload 1.0.  I'm in a situation wherein:
>> > >
>> > >  - if the user submits a file larger than my defined maxFileSize,
>> > > FileUploadBase throws a SizeLimitExceededException which stops
>> processing
>> > > of
>> > > the remaining parameters.
>> > >  - i have a hidden field in my form that my web application needs to
>> > > retrieve even in the case of an exceeded size limit.
>> > >
>> > > Does anyone have ideas on possible solutions here?
>> > >
>> > > I have not yet tried using the latest release,
>> commons-fileupload-1.2.1.
>> > > But skimming through the code, things look similar.  It looks like the
>> > > exception will still be thrown before the rest of the parameters get
>> > read.
>> > >
>> > > Best Regards,
>> > > Paul Rivera
>> > >
>> > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> > > For additional commands, e-mail: user-help@commons.apache.org
>> > >
>> > >
>> >
>>
>
>

Re: fileupload sizelimitexception

Posted by Paul Rivera <pa...@gmail.com>.
Hi fas,

Looks like my problem is harder to solve than it seems.  I've created a jira
entry for a proposed enhancement in fileupload that could help me solve this
bug I'm working on.  Here's the link if you are interested:
https://issues.apache.org/jira/browse/FILEUPLOAD-168

Thanks for the help!

Best Regards,
Paul Rivera

On Sat, Oct 11, 2008 at 9:24 PM, F. Andy Seidl
<fa...@myst-technology.com>wrote:

> Hi Paul,
>
> The problem with putting the hidden field at the end of the form is that it
> will be sent to your server *after* the other fields.  Your server won't
> physically have the hidden field until after it has read the data of all
> the
> other fields, which is too late.  In other words, you can never access data
> send *after* the file content without reading all the file content since
> the
> input stream is a not a random access beast.
>
> It seems to me that to ensure you see the hidden field you must either a)
> move the hidden field ahead of the other fields or b) read the entire file
> content, regardless of its size.
>
> -- fas
>
> -----Original Message-----
> From: Paul Rivera [mailto:paulrivera22@gmail.com]
> Sent: Wednesday, October 01, 2008 9:43 AM
> To: Commons Users List
> Subject: Re: fileupload sizelimitexception
>
> Thanks for the info!
>
> The hidden field that I need is located just before the end tag of my form.
> Relocating it to some part in the beginning will be tough.  It will
> probably
> be a last resort.
>
> I'm wondering if:
>  - I could still retrieve all my form fields even though I exceed the size
> limit (including parameters before and after my file upload field)
>  - even better if I can skip reading the file since its size is already not
> acceptable and read only my field parameters from my web app.  Thus saving
> some time by not waiting for the upload to complete.
>
> Best Regards,
> Paul Rivera
>
> On Wed, Oct 1, 2008 at 12:56 AM, Martin Cooper <ma...@apache.org> wrote:
>
> > On Tue, Sep 30, 2008 at 9:52 AM, Paul Rivera <pa...@gmail.com>
> > wrote:
> >
> > > Hi!
> > >
> > > Thanks for the quick response.
> > >
> > > Yes, I have.  Sorry for the vagueness but let me clear things up a
> > little.
> > >
> > > FileUploadBase.parseRequest() returns a List containing FileItem
> objects.
> > > These FileItem objects can either be a file uploaded or a form field
> > (these
> > > form fields are what I need).
> > >
> > > In commons fileupload 1.0, FileUploadBase.parseRequest() throws an
> > > Exception
> > > if the maxSize is exceeded _before it even starts to read from the
> > > MultipartStream.  Meaning, it will not even read the first form field.
> > >
> > > I've looked into fileupload 1.2.1 and the flow looks pretty much the
> > same.
> >
> >
> > If you use the streaming mode in 1.2, you should be able to capture the
> > hidden field before you hit the max size limit.
> >
> > --
> > Martin Cooper
> >
> >
> > I was hoping I could make FileUploadBase.parseRequest() still return the
> > > form fields (but exclude the data from the uploaded file) even in the
> > case
> > > when the maxSize is exceeded.
> > >
> > > Any ideas?
> > >
> > > Best Regards,
> > > Paul Rivera
> > >
> > > On Tue, Sep 30, 2008 at 11:36 PM, F. Andy Seidl <
> > > faseidl@myst-technology.com
> > > > wrote:
> > >
> > > > Have you tried placing the hidden form field before the upload field
> in
> > > the
> > > > form?
> > > >  -- fas
> > > >
> > > > -----Original Message-----
> > > > From: Paul Rivera [mailto:paulrivera22@gmail.com]
> > > > Sent: Tuesday, September 30, 2008 10:02 AM
> > > > To: user@commons.apache.org
> > > > Subject: fileupload sizelimitexception
> > > >
> > > > Hi!
> > > >
> > > > I'm using commons fileupload 1.0.  I'm in a situation wherein:
> > > >
> > > >  - if the user submits a file larger than my defined maxFileSize,
> > > > FileUploadBase throws a SizeLimitExceededException which stops
> > processing
> > > > of
> > > > the remaining parameters.
> > > >  - i have a hidden field in my form that my web application needs to
> > > > retrieve even in the case of an exceeded size limit.
> > > >
> > > > Does anyone have ideas on possible solutions here?
> > > >
> > > > I have not yet tried using the latest release,
> > commons-fileupload-1.2.1.
> > > > But skimming through the code, things look similar.  It looks like
> the
> > > > exception will still be thrown before the rest of the parameters get
> > > read.
> > > >
> > > > Best Regards,
> > > > Paul Rivera
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > > > For additional commands, e-mail: user-help@commons.apache.org
> > > >
> > > >
> > >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

RE: fileupload sizelimitexception

Posted by "F. Andy Seidl" <fa...@myst-technology.com>.
Hi Paul,

The problem with putting the hidden field at the end of the form is that it
will be sent to your server *after* the other fields.  Your server won't
physically have the hidden field until after it has read the data of all the
other fields, which is too late.  In other words, you can never access data
send *after* the file content without reading all the file content since the
input stream is a not a random access beast.

It seems to me that to ensure you see the hidden field you must either a)
move the hidden field ahead of the other fields or b) read the entire file
content, regardless of its size.

-- fas

-----Original Message-----
From: Paul Rivera [mailto:paulrivera22@gmail.com] 
Sent: Wednesday, October 01, 2008 9:43 AM
To: Commons Users List
Subject: Re: fileupload sizelimitexception

Thanks for the info!

The hidden field that I need is located just before the end tag of my form.
Relocating it to some part in the beginning will be tough.  It will probably
be a last resort.

I'm wondering if:
  - I could still retrieve all my form fields even though I exceed the size
limit (including parameters before and after my file upload field)
  - even better if I can skip reading the file since its size is already not
acceptable and read only my field parameters from my web app.  Thus saving
some time by not waiting for the upload to complete.

Best Regards,
Paul Rivera

On Wed, Oct 1, 2008 at 12:56 AM, Martin Cooper <ma...@apache.org> wrote:

> On Tue, Sep 30, 2008 at 9:52 AM, Paul Rivera <pa...@gmail.com>
> wrote:
>
> > Hi!
> >
> > Thanks for the quick response.
> >
> > Yes, I have.  Sorry for the vagueness but let me clear things up a
> little.
> >
> > FileUploadBase.parseRequest() returns a List containing FileItem
objects.
> > These FileItem objects can either be a file uploaded or a form field
> (these
> > form fields are what I need).
> >
> > In commons fileupload 1.0, FileUploadBase.parseRequest() throws an
> > Exception
> > if the maxSize is exceeded _before it even starts to read from the
> > MultipartStream.  Meaning, it will not even read the first form field.
> >
> > I've looked into fileupload 1.2.1 and the flow looks pretty much the
> same.
>
>
> If you use the streaming mode in 1.2, you should be able to capture the
> hidden field before you hit the max size limit.
>
> --
> Martin Cooper
>
>
> I was hoping I could make FileUploadBase.parseRequest() still return the
> > form fields (but exclude the data from the uploaded file) even in the
> case
> > when the maxSize is exceeded.
> >
> > Any ideas?
> >
> > Best Regards,
> > Paul Rivera
> >
> > On Tue, Sep 30, 2008 at 11:36 PM, F. Andy Seidl <
> > faseidl@myst-technology.com
> > > wrote:
> >
> > > Have you tried placing the hidden form field before the upload field
in
> > the
> > > form?
> > >  -- fas
> > >
> > > -----Original Message-----
> > > From: Paul Rivera [mailto:paulrivera22@gmail.com]
> > > Sent: Tuesday, September 30, 2008 10:02 AM
> > > To: user@commons.apache.org
> > > Subject: fileupload sizelimitexception
> > >
> > > Hi!
> > >
> > > I'm using commons fileupload 1.0.  I'm in a situation wherein:
> > >
> > >  - if the user submits a file larger than my defined maxFileSize,
> > > FileUploadBase throws a SizeLimitExceededException which stops
> processing
> > > of
> > > the remaining parameters.
> > >  - i have a hidden field in my form that my web application needs to
> > > retrieve even in the case of an exceeded size limit.
> > >
> > > Does anyone have ideas on possible solutions here?
> > >
> > > I have not yet tried using the latest release,
> commons-fileupload-1.2.1.
> > > But skimming through the code, things look similar.  It looks like the
> > > exception will still be thrown before the rest of the parameters get
> > read.
> > >
> > > Best Regards,
> > > Paul Rivera
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: user-help@commons.apache.org
> > >
> > >
> >
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org