You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Martin <ja...@yahoo.com> on 2009/12/28 23:40:46 UTC

problems using progresslistener with servletfileupload

Hello,

I am having a very frustrating problem with servletfileupload and progresslistener. I am using commons-fileupload-1.2.1.jar and commons-io-1.4.jar. I would very much like to implement a file upload feature which gives some feedback to the user about the progress so they don't become impatient and give up. To do this I have attached a progresslistener to a servletfileupload as described here:

http://commons.apache.org/fileupload/using.html

But I am having a very hard time getting this to work right. After much debugging I have managed to figure out that every single call to update in the progresslistener interface takes place during the call to upload.parseRequest(request) which typically only takes a few milliseconds right at the very end. Currently I am uploading images which take about 5-10 seconds to upload and during most of the upload the progress is undefined and then right at the end it jumps to 100% which is consistent with my debugging. So my question is what am I doing wrong? How do I get the update function in the progresslistener interface to be called periodically while the file is being uploaded instead of only at the very end when it is being processed?

Thanks for any help!

Regards,
Martin


      

Re: problems using progresslistener with servletfileupload

Posted by Martin <ja...@yahoo.com>.
Hello Martin,

Thanks for your prompt reply! What you are saying certainly explains the problem I am having in that my expectations were incorrect. I must admit though that I am very surprised by this behavior. Even after rereading the documentation I am still left with the impression that progresslistener is intended to give feedback as the file is being uploaded but this is not explicitly stated anywhere. Now I am wondering why even have a progresslistener? Is this feature useful for anything besides indicating how much of a file has been processed right at the very end which doesn't seem that useful to me? Thanks again for your help!

Regards,
Martin



________________________________
From: Martin Cooper <ma...@apache.org>
To: Commons Users List <us...@commons.apache.org>
Sent: Tue, December 29, 2009 12:10:03 AM
Subject: Re: problems using progresslistener with servletfileupload

This is why earlier versions of Commons FileUpload didn't have a
progress API - it's not possible to make it work as people expect.

For the servlet containers I'm familiar with, the container receives
the request and stores it in its entirety prior to invoking any
servlets or filters or whatever. That means that the actual upload of
the data from the browser to the server has already happened before
Commons FileUpload has any chance to even see the request, let alone
initialise a progress mechanism. So the progress mechanism is tracking
the progress of processing the upload once it's already on the server,
not the progress of the upload itself.

I believe the only way you're going to be able to track the process of
the upload itself is to find a container-specific API that lets you
see the request as it comes in. I don't know that any of them actually
have such a thing, though, so you may be out of luck. (I do seem to
recall that Resin has multipart requests somewhat more baked in, so it
may have something in place, but it's been a long time since I've
looked at it.)

--
Martin Cooper


On Mon, Dec 28, 2009 at 2:40 PM, Martin <ja...@yahoo.com> wrote:
> Hello,
>
> I am having a very frustrating problem with servletfileupload and progresslistener. I am using commons-fileupload-1.2.1.jar and commons-io-1.4.jar. I would very much like to implement a file upload feature which gives some feedback to the user about the progress so they don't become impatient and give up. To do this I have attached a progresslistener to a servletfileupload as described here:
>
> http://commons.apache.org/fileupload/using.html
>
> But I am having a very hard time getting this to work right. After much debugging I have managed to figure out that every single call to update in the progresslistener interface takes place during the call to upload.parseRequest(request) which typically only takes a few milliseconds right at the very end. Currently I am uploading images which take about 5-10 seconds to upload and during most of the upload the progress is undefined and then right at the end it jumps to 100% which is consistent with my debugging. So my question is what am I doing wrong? How do I get the update function in the progresslistener interface to be called periodically while the file is being uploaded instead of only at the very end when it is being processed?
>
> Thanks for any help!
>
> Regards,
> Martin
>
>
>

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


      

Re: problems using progresslistener with servletfileupload

Posted by Martin Cooper <ma...@apache.org>.
This is why earlier versions of Commons FileUpload didn't have a
progress API - it's not possible to make it work as people expect.

For the servlet containers I'm familiar with, the container receives
the request and stores it in its entirety prior to invoking any
servlets or filters or whatever. That means that the actual upload of
the data from the browser to the server has already happened before
Commons FileUpload has any chance to even see the request, let alone
initialise a progress mechanism. So the progress mechanism is tracking
the progress of processing the upload once it's already on the server,
not the progress of the upload itself.

I believe the only way you're going to be able to track the process of
the upload itself is to find a container-specific API that lets you
see the request as it comes in. I don't know that any of them actually
have such a thing, though, so you may be out of luck. (I do seem to
recall that Resin has multipart requests somewhat more baked in, so it
may have something in place, but it's been a long time since I've
looked at it.)

--
Martin Cooper


On Mon, Dec 28, 2009 at 2:40 PM, Martin <ja...@yahoo.com> wrote:
> Hello,
>
> I am having a very frustrating problem with servletfileupload and progresslistener. I am using commons-fileupload-1.2.1.jar and commons-io-1.4.jar. I would very much like to implement a file upload feature which gives some feedback to the user about the progress so they don't become impatient and give up. To do this I have attached a progresslistener to a servletfileupload as described here:
>
> http://commons.apache.org/fileupload/using.html
>
> But I am having a very hard time getting this to work right. After much debugging I have managed to figure out that every single call to update in the progresslistener interface takes place during the call to upload.parseRequest(request) which typically only takes a few milliseconds right at the very end. Currently I am uploading images which take about 5-10 seconds to upload and during most of the upload the progress is undefined and then right at the end it jumps to 100% which is consistent with my debugging. So my question is what am I doing wrong? How do I get the update function in the progresslistener interface to be called periodically while the file is being uploaded instead of only at the very end when it is being processed?
>
> Thanks for any help!
>
> Regards,
> Martin
>
>
>

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