commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <mfncoo...@gmail.com>
Subject Re: FileUpoad:
Date Fri, 22 Apr 2005 04:23:27 GMT
The solution below works only if you are prepared to store as much
data as the client wants to send. However, the size check in
FileUpload is designed to prevent exactly that.

If the client wants to upload a 2GB file, and you use the code below,
then you'd better have 2GB available to store that request, because
parseRequest() won't return until it's done parsing all that data. The
point of the size check in FileUpload is so that FileUpload knows when
to ignore the incoming stream. (Unfortunately, the container will
continue to receive it, but that's a separate issue.)

To answer your original question in this thread, no, it's not
currently possible to access items prior to one that blows the limit.
However, I can see how that might be useful in some constrained
situations, so feel free to file an enhancement request in the bug
database for that.

--
Martin Cooper


On 4/21/05, Tom Eugelink <tbee@tbee.org> wrote:
> Thanks Dakota,
> 
> The solution was very simple:
> 
> ...
> 
>         // we always want to be able to get the ID
>         // so we do the filesize check ourselves
>          int lRequestSize = request.getContentLength();
>         lFileUpload.setSizeMax(lRequestSize);
> 
> ...
> 
>         lFileItems = lFileUpload.parseRequest(request);
> 
> ...
>         //
>         // manually check the size
>          if (iMaxSize >= 0 && lRequestSize > iMaxSize)
>          {
>                 response.sendRedirect(iOnError + "?id=" + lId);
>                 return;
>          }
> 
> Great help.
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

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


Mime
View raw message