there is no text fields. just the file upload. investigating the post request, i noticed that its the stuff like file name, etc, and 2 or 3 extra fields.
also, I am posting only one file, therefore no multiple items. from my measurements the extra overhead is 100-200 Bytes max. considering I want to cap the upload at 2mb, that will be a insignificant delta between the actual file size and the request size. but I am wondering cross browser stuff, or maybe one browser chunks the post into two, or something that I do not know. Best Regards, -C.A. On Sun, Jul 12, 2009 at 5:29 AM, Martin Cooper<[email protected]> wrote: > On Sat, Jul 11, 2009 at 7:12 PM, Cam Bazz <[email protected]> wrote: > >> Martin; >> >> how reliable would be to get the content-length from the request header. > > > It's completely reliable as a measure of the size of the *request*, but > hopeless as a measure of the size of an individual item, file or otherwise. > Think about it - the request size not including file items is completely > dependent on the complexity of the form it's part of, and on the amount of > text the user has entered in any text fields in that form. > > -- > Martin Cooper > > > >> >> i made some tests, and it seems that the content-length obtained from >> the request header is a little bit greater in file size. >> >> i am not sure how reliable that method would be, >> >> best regards, >> Can >> >> On Sun, Jul 12, 2009 at 4:29 AM, Martin Cooper<[email protected]> wrote: >> > On Sat, Jul 11, 2009 at 6:15 PM, Cam Bazz <[email protected]> wrote: >> > >> >> yes, I am wondering if there is any way to get the file size of an >> >> uploaded file before the file is uploaded. >> > >> > >> > Not if you're expecting the browser to do the uploading for you. If you >> want >> > to write your own upload client, then sure. >> > >> > Commons FileUpload is designed to work with browser implementations of >> RFC >> > 1867. It can't make the browser do something different from that. >> > >> > -- >> > Martin Cooper >> > >> > >> > it seems that only after parsing the upload request, the uploader will >> >> throw the sizelimitexceeded exception. >> >> >> >> getting the content-length from the request header is a way, but not >> >> precise. >> >> >> >> best regards, >> >> -c.b. >> >> >> >> On Sat, Jul 11, 2009 at 6:04 PM, Tushar Kale<[email protected]> wrote: >> >> > Hello: >> >> > I am using Streaming API for of FileUpload. >> >> > How do I get the length of the file? >> >> > >> >> > In the following code, the item.getHeaders() call returns null >> headers. >> >> > >> >> > FileItemIterator iter = upload.getItemIterator(request); >> >> > while (iter.hasNext()) { >> >> > FileItemStream item = iter.next(); >> >> > String name = item.getFieldName(); >> >> > InputStream stream = item.openStream(); >> >> > >> >> > FileItemHeaders headers = item.getHeaders(); >> >> > if (headers == null) >> >> > { >> >> > System.out.println("headers are null"); >> >> > } else { >> >> > System.out.println("headers are not null"); >> >> > } >> >> > } >> >> > >> >> > ~ Tushar >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [email protected] >> >> For additional commands, e-mail: [email protected] >> >> >> >> >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
