Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > uupload with progressbar

Reply
Thread Tools

uupload with progressbar

 
 
autogoor@yahoo.com
Guest
Posts: n/a
 
      03-01-2005
I am uploading files via POST to a web server, from the client.
Everything works great, the uploading, the reading of the file, works
100% perfect.


The problem is I can't figure out how to add a progress bar to a
single-file upload. I can't seem to figure out how many bytes have
actually been SENT over the internet connection.


I am using DataOutputStream and httpUrlConnection


Does anyone have any suggestions, ideas, or samples?


Thanks very much, I really appreciate it.

 
Reply With Quote
 
 
 
 
Daniel Tryba
Guest
Posts: n/a
 
      03-01-2005
In comp.lang.java.help wrote:
> I am uploading files via POST to a web server, from the client.
> Everything works great, the uploading, the reading of the file, works
> 100% perfect.
>
> The problem is I can't figure out how to add a progress bar to a
> single-file upload. I can't seem to figure out how many bytes have
> actually been SENT over the internet connection.
>
> I am using DataOutputStream and httpUrlConnection


AFAIK you can't. httpUrlConnection has the nasty habit of buffering all
output and sending it in 1 batch (atleast that was the case in pre 1.5).
This can easlity be tested by sending *large* files.

You'll have to find an other http connection class that will give you
that option.

 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      03-01-2005
wrote:
> The problem is I can't figure out how to add a progress bar to a
> single-file upload. I can't seem to figure out how many bytes have
> actually been SENT over the internet connection.
>
>
> I am using DataOutputStream and httpUrlConnection
>
>
> Does anyone have any suggestions, ideas, or samples?


I haven't tried this, but:

use one of the set...StreamingMode() methods, so HttpURLConnection
doesn't buffer (you need to provide a chunk size or the total file
length, depending on the streaming mode you want to use). Then wrap the
file reading in a ProgressMonitorInputStream.

If you use the fixed' length mode, don't put any (large) buffers between
the InputStream and your code which copies the input stream to the
HttpURLConnection's output stream. Then the display should be reasonably
"accurate". Of course, you should put a BufferedReader around the
initial FileInputStream. Note, you do *not* want the order in the
example of the ProgressMonitorInputStream's API documentation.

Using chunked streaming mode might be the better alternative of the two
modes. If you do so, you could e.g. match chunk size and any internal
buffer size which might turn out to be useful.

/Thomas

--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ANN: progressbar 2.2 - Text mode progressbar for console applications Nilton Volpato Python 0 05-08-2006 05:28 AM
ANN: progressbar 2.2 - Text mode progressbar for console applications Nilton Volpato Python 0 05-07-2006 07:47 PM
Missing POST upload progressbar snusken Firefox 2 05-17-2005 04:17 PM
C# question: how do I make the ProgressBar dimmed/gray Maka Sili ASP .Net 0 08-25-2004 02:42 PM
C# question: how do I make the ProgressBar dimmed/gray Maka Sili ASP .Net 0 08-25-2004 02:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57