commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian K Bonner <brian.bon...@paraware.com>
Subject RE: [HttpClient] Http MultipartpostMethod progress
Date Fri, 13 Jun 2003 02:36:20 GMT
Thanks.  based on your note, I did some further research.  I found that 
EntityEnclosingMethod supports sending an InputStream.  This appears to be 
the only one that supports this.

The standard Multipart post accepts java.io.File objects.  I'm a bit 
confused though.  I was interested in having progress on a file by file 
basis.  It seems like the FilePartSource could be potentially modified to 
support this.  I searched the commons-dev archives, but I couldn't find 
any examples except:

public abstract class EntityEnclosingMethod extends GetMethod {
   [...]
   private List progressListeners = new ArrayList();
   [...]
   public void addProgressListener(ProgressListener listener) {
     progressListeners.add(listener);
   }

   public List getProgressListeners() { return progressListeners; }

   protected boolean writeRequestBody(
       HttpState state, HttpConnection conn) {
     //...
     if (progressListeners.isEmpty()) {
       InputStream instream = getRequestBody();
     } else {
       InputStream instream = new ProgressInputStream(
                                    getRequestBody(),
                                    getProgressListeners());
     }
     // ...
}

public class ProgressInputStream extends FilterInputStream {
   // ...
   public ProgressInputStream(InputStream is, List progressListeners) {
     //...
   }
   // ...
   private void bytesRead(int count) {
     bytesRead+=count;
     if (progressListeners==null || progressListeners.isEmpty()) return;
     for (int i=0; i<progressListeners.size();i++) {
       ProgressListener l = (ProgressListener)progressListeners.get(i);
       if (bytesRead > l.getThreshold()) {
         totalBytesRead += bytesRead;
         bytesRead = 0;
         l.progressAchieved(totalBytesRead);
       }
     }
   }
}

Did I misunderstand your suggestion?  I couldn't find anything related to 
InputStreams in the MultipartPostMethod.

Thank you,

Brian


Adrian Sutton <Adrian.Sutton@Ephox.com> wrote on 06/09/2003 06:36:02 PM:

> It is indeed possible to do, but it's done differently to how you might
> expect.  Essentially, HttpClient doesn't provide any feedback itself 
(this
> has been mentioned as a possible future addition though), but since you 
pass
> in the InputStream to HttpClient, you can add a wrapper around it that
> provides feedback.  There may even be an example in the contrib 
directory in
> CVS I'm not sure.  This has definitely been mentioned before over on the
> HttpClient dev list so searching those archives would be good.  The 
links
> are available from http://jakarta.apache.org/commons/httpclient it's 
first
> thing back after a long weekend so I can't remember them off the top of 
my
> head. ;)
> 
> If you need more detail let me know and I'll think about it once I'm 
fully
> awake.
> 
> Regards,
> 
> Adrian Sutton, Software Engineer
> Ephox Corporation
> www.ephox.com 
> 
> -----Original Message-----
> From: Brian Bonner [mailto:brian.bonner@paraware.com]
> Sent: Friday, 6 June 2003 11:22 PM
> To: commons-user@jakarta.apache.org
> Subject: Http MultipartpostMethod progress
> 
> 
> It doesn't look like it's possible from the api, but I was wondering if 
> anyone came up with a way of tracking the progress on an http post (file 

> upload).
> --Brian
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


Mime
View raw message