Return-Path: Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@www.apache.org Received: (qmail 52082 invoked from network); 11 Nov 2003 08:45:47 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 11 Nov 2003 08:45:47 -0000 Received: (qmail 46347 invoked by uid 500); 11 Nov 2003 08:45:22 -0000 Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@jakarta.apache.org Received: (qmail 46325 invoked by uid 500); 11 Nov 2003 08:45:22 -0000 Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Commons HttpClient Project" Reply-To: "Commons HttpClient Project" Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 46311 invoked from network); 11 Nov 2003 08:45:21 -0000 Received: from unknown (HELO KCCXOEX10.corp.kpmgconsulting.com) (57.80.136.22) by daedalus.apache.org with SMTP; 11 Nov 2003 08:45:21 -0000 Received: from kccxoex06.corp.kpmgconsulting.com ([10.98.3.31]) by KCCXOEX10.corp.kpmgconsulting.com with Microsoft SMTPSVC(5.0.2195.5329); Tue, 11 Nov 2003 08:45:41 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: file upload (PUT method) progress report Date: Tue, 11 Nov 2003 08:45:33 -0000 Message-ID: <825BF35A92B3F0479CC164ECBBE9376E0DE64D@kccxoex06.corp.kpmgconsulting.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: file upload (PUT method) progress report Thread-Index: AcOn5sJ/iEaxYJI6T3OKY4AGqB8QGAAR4Uqw From: "Kalnichevski, Oleg" To: "Commons HttpClient Project" X-OriginalArrivalTime: 11 Nov 2003 08:45:41.0984 (UTC) FILETIME=[305D8E00:01C3A830] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Yong, You should be using PostMethod.setRequestBody(InputStream) method to = provide the request content body (as Mike pointed out) and wrap the = source InputStream with a FilterInputStream. Exactly what you choose to = do in the FilterInputStream is up to you. One possibility is to file = events containing progress details. Here's a code snippet that should = give you a pointer in that direction. Hope this helps Oleg =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D import java.util.EventObject; public class ProgressEvent extends EventObject { private int current; =20 private int total; =20 =20 public ProgressEvent( Object source, int current, int total ) { super( source ); this.current =3D current; this.total =3D total; } =20 public int getCurrent() { return this.current; } =20 =20 public int getTotal() { return this.total; } =20 } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import xxx.ProgressEvent;=20 import xxx.ProgressListenerList;=20 public class ProgressInputStream extends FilterInputStream { private ProgressListenerList listeners =3D null; private int current; private int total; public ProgressInputStream( InputStream in, ProgressListenerList = listeners, int total ) { super( in ); this.listeners =3D listeners; this.current =3D 0; this.total =3D total; } =20 public int read(byte[] b, int off, int len) throws IOException { int result =3D super.read(b, off, len); if ( result !=3D -1 ) { this.current +=3D result; callListeners(); =20 } return result; } public int read(byte[] b) throws IOException { int result =3D super.read(b); if ( result !=3D -1 ) { this.current +=3D result; callListeners(); =20 } return result; } private void callListeners() { if ( this.listeners !=3D null ) { this.listeners.callListeners( new ProgressEvent( this, = this.current, this.total ) ); } } } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D import java.util.EventListener; public interface ProgressListener extends EventListener { public void progressNotification( ProgressEvent event ); } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D import java.util.Vector;=20 public class ProgressListenerList { // I have to use Vector here because of Java 1.1.8 compatibiliy = requirements private Vector v =3D null; public ProgressListenerList() { super(); } public synchronized void addListner( ProgressListener listnener ) { if ( listnener =3D=3D null ) { return; } if ( this.v =3D=3D null ) { this.v =3D new Vector( 1 ); } int i =3D this.v.indexOf( listnener ); if ( i =3D=3D -1 ) { this.v.addElement( listnener ); } =20 } public synchronized void removeListner( ProgressListener listnener ) { if ( listnener =3D=3D null ) { return; } if ( this.v =3D=3D null ) { return; } int i =3D this.v.indexOf( listnener ); if ( i !=3D -1 ) { this.v.removeElementAt( i ); } =20 if ( this.v.size() =3D=3D 0 ) { this.v =3D null; } } public synchronized void clear() { if ( this.v !=3D null ) { this.v.removeAllElements(); this.v =3D null; } } public synchronized void invokeListeners( ProgressEvent event ) { if ( this.v =3D=3D null ) { return; } for ( int i =3D 0; i < this.v.size(); i++ ) { ( ( ProgressListener )this.v.elementAt( i ) = ).progressNotification( event ); } } public synchronized int size() { if ( this.v =3D=3D null ) { return 0; } else { return this.v.size(); } } } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D -----Original Message----- From: Yong Chen [mailto:Yong.Chen@MCDATA.com] Sent: Tuesday, November 11, 2003 01:03 To: commons-httpclient-dev@jakarta.apache.org Subject: file upload (PUT method) progress report Hi, I'm using putmethod to put (large size) file on server. After calling = executeMethod(), I want to know the progress or the percentage of file = uploaded so I can report it to UI. 1. Is there any to do it now? 2. If not, are there any plans for adding it to the future release? Thanks, Yong Chen SPECIAL NOTICE=20 All information transmitted hereby is intended only for the use of the=20 addressee(s) named above and may contain confidential and privileged=20 information. Any unauthorized review, use, disclosure or distribution of confidential and privileged information is prohibited. If the reader = of this message is not the intended recipient(s) or the employee or agent=20 responsible for delivering the message to the intended recipient, you are herby notified that you must not read this transmission and that disclosure, copying, printing, distribution or use of any of the information contained in or attached to this transmission is STRICTLY=20 PROHIBITED. Anyone who receives confidential and privileged information in error = should=20 notify us immediately by telephone and mail the original message to us = at the above address and destroy all copies. To the extent any portion of this communication contains public information, no such restrictions=20 apply to that information. (gate01) --------------------------------------------------------------------- To unsubscribe, e-mail: = commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: = commons-httpclient-dev-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org