commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <>
Subject Re: [FileUpload] checking item sizes before reading
Date Tue, 25 Mar 2003 04:20:25 GMT

On Mon, 24 Mar 2003 wrote:

> I am trying to use the FileUpload object to determine one by one whether
> or not a file should be uploaded based on its size.  I commented out the
> code in parseRequest() that throws an exception if the request is too
> big, and when I get the list back I can check the item size before I
> write it to the disk, but the problem is the data is still read, so if
> it is a large file it takes too long to process.  Is there a way to
> determine the size of the current item before calling
> multi.readBodyData(os); in parseRequest?  I tried checking the item
> size, but it always returns 0 at this point.

No, there isn't a way to check the size of an individual item and skip it,
since the item size is not sent by the browser.

However, I am working on some changes to FileUpload that might allow you
to build what you want. Essentially, the idea is to use a thresholding
stream for each file item. The default implementation will keep item data
in memory until it reaches a configured threshold, and then switch over to
writing to disk when the threshold is exceeded. I'm also introducing a
file item factory, so you should be able to easily override the default
implementation for your needs.

These changes should appear in the nightly builds within a few days.

Martin Cooper

> Thanks
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message