tags:

views:

8260

answers:

6

All Gmail users should have already noticed that file upload progress bar has been updated recently.

I'm wondering such effect is possible to implement with GWT. I'm fairly new with GWT, so if any GWT source code that can help me test out the function would be very helpful.

Update
I ended up going with SWFUpload. However, other suggestions under this question are all valid. Just try different options and choose the one you like!

+2  A: 

Check out GWTC Upload, which has an implementation of exactly what you're looking for.

John Feminella
I don't see anything useful there. Usually, there is source code available for download or view.
bLee
Click the source tab: # Non-members may check out a read-only working copy anonymously over HTTP.svn checkout http://gwtcupload.googlecode.com/svn/trunk/ gwtcupload-read-only
rustyshelf
+1  A: 

It's trivial to write your own if you have a java back end, you just start a file upload and then poll the server on a timer to see where it's up to (say every second or two). The java file upload binaries (the apache commons ones) support telling you the current progress so it's trivial to do.

rustyshelf
Hm, I thought it could be more elegant because polling the server every sec is too troublesome, especially web apps that have network bottleneck all the time. (maybe I'm not seeing from what you are trying to say?)
bLee
a non-polling technique is to use a flash uploader. This is how getdropbox.com does their uploading - it looks awesome, and you can upload files in parallel i believe. Check it out at www.getdropbox.com
Chii
@Chii, that's what I figured out. I think Gmail also uses flash uploader, because they embedded swf file. Do you know how to do that in flash and integrate with a typical web app? (I already know Dropbox :D)
bLee
Polling every second and sending less than 1kb of data is pretty tiny. Unless you have 10,000 users I don't see the problem?
rustyshelf
The problem with no-polling is you have to implement some "comet-style" solution. It is: the server has to alert the client when it's ready, and it means the client has to mantain an open connection, and it means the classic servlet api doesn't scale well (I think servlet3.0 includes a solution for this gap)
helios
+2  A: 

Use SWFUpload via swfupload-gwt

The main advantage over the other methods is this does not require any special server code. You could even upload to another domain (if there is a crossdomain.xml which allows it).

Mark Renouf
Also... this is (hopefully) a short term solution, as soon I hope that features provided by Gears will be available natively in browsers. http://code.google.com/apis/gears/api_httprequest.html#HttpRequestUpload
Mark Renouf
A: 

You can use GwtSwfExt which is wrapper on top of SWFUpload (Its same as Swfupload-gwt lib ) you can download example and source code from http://code.google.com/p/gwtswfext.

A: 

When creating your own file upload progress, instead of pulling it form server at a small set time, you can have the client to display a indeterminate bar for 2 seconds and have the server calculate the estimated finish time the change back to determinate and pull new estimates every 5, 10 seconds instead. that should have little to no effect on the traffic.

Ning120
+10  A: 

Take a look to this library: http://code.google.com/p/gwtupload/. It is really easy to to use and works fine in all browsers and OS I've checked. It uses ajax requests to calculate progress. BTW Swfupload doesn't do well in linux and Mac.

mcdodot
yes, this is what I ended up using in the end. It is very easy to install and integrate.
bLee