commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Scott.ANDER...@takgroup.net>
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?

Thanks.

-----Original Message-----
From: Martin Cooper [mailto:martinc@apache.org]
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 Scott.ANDERSON@takgroup.net 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: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>

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


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


Mime
View raw message