You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Cindy Ballreich <ci...@ballreich.net> on 2003/06/09 21:12:15 UTC

[FileUpload] parsing part of a request

In the event that the parseRequest(request) method of DiskFileUpload throws an exception (FileUploadBase.SizeLimitExceededException for example), is there a way to reject the FileItem that caused the exception and finish parsing the rest of the request so that the other FileItems can be retrieved (especially the FormFields)?

Thanks

Cindy

Re: [FileUpload] parsing part of a request

Posted by Martin Cooper <ma...@apache.org>.
"Cindy Ballreich" <ci...@ballreich.net> wrote in message
news:3.0.5.32.20030610091704.00b4ba70@urchin...
> At 05:50 PM 6/9/03 -0700, Martin Cooper wrote:
> >
> >If SizeLimitExceededException is thrown, that happens before parsing of
> >the multipart body even starts, since the size limit is based on the size
> >of the entire request.
>
> So setSizeMax sets the total size of the request and not the maximum size
of individual files in the request? This means that if two files were
uploaded that were each smaller than SizeMax, but when combined were larger,
a SizeLimitExceededException would be thrown. Is this correct?

Yes, that's correct. What you specify in setSizeMax() is compared with
what's returned by request.getContentLength().

--
Martin Cooper


>
> Cindy




Re: [FileUpload] parsing part of a request

Posted by Cindy Ballreich <ci...@ballreich.net>.
At 05:50 PM 6/9/03 -0700, Martin Cooper wrote:
>
>If SizeLimitExceededException is thrown, that happens before parsing of
>the multipart body even starts, since the size limit is based on the size
>of the entire request.

So setSizeMax sets the total size of the request and not the maximum size of individual files in the request? This means that if two files were uploaded that were each smaller than SizeMax, but when combined were larger, a SizeLimitExceededException would be thrown. Is this correct?

Cindy

Re: [FileUpload] parsing part of a request

Posted by Martin Cooper <ma...@apache.org>.

On Mon, 9 Jun 2003, Cindy Ballreich wrote:

>
> In the event that the parseRequest(request) method of DiskFileUpload throws an exception (FileUploadBase.SizeLimitExceededException for example), is there a way to reject the FileItem that caused the exception and finish parsing the rest of the request so that the other FileItems can be retrieved (especially the FormFields)?

If SizeLimitExceededException is thrown, that happens before parsing of
the multipart body even starts, since the size limit is based on the size
of the entire request.

One thing you could do is write your own FileItem implementation that
discards data beyond a configured threshold. This wouldn't solve the
problem of the overall request size, but it would let you control the
maximum size of an individual file item, and continue the parse even if
one or more items exceed the limit. You'd have to set the overall maximum
size high enough so that SizeLimitExceededException would not be
triggered, of course.

Feel free to file an enhancement request in the bug database, and we can
think about it some more for a post-1.0 release.

--
Martin Cooper


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