commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject RE: [FileUpload] checking item sizes before reading
Date Tue, 25 Mar 2003 18:26:00 GMT
I'm trying to modify readBodyData() to stop reading once sizeMax bytes
has been read but am running into some problems.  If you can think of an
easy way to do this could you let me know?


-----Original Message-----
From: Martin Cooper []
Sent: Monday, March 24, 2003 8:20 PM
To: Jakarta Commons Developers List
Subject: Re: [FileUpload] checking item sizes before reading

On Mon, 24 Mar 2003 wrote:

> I am trying to use the FileUpload object to determine one by one
> or not a file should be uploaded based on its size.  I commented out
> 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
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
in memory until it reaches a configured threshold, and then switch over
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:

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

View raw message