commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <mart...@apache.org>
Subject Re: Getting file length while using stream api of file upload
Date Sun, 12 Jul 2009 01:29:56 GMT
On Sat, Jul 11, 2009 at 6:15 PM, Cam Bazz <cambazz@gmail.com> 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<tkale@w3apps.com> 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: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message