Interface MediaHttpUploaderProgressListener (1.34.1)

public interface MediaHttpUploaderProgressListener

An interface for receiving progress notifications for uploads.

Sample usage (if media content length is provided, else consider using MediaHttpUploader#getNumBytesUploaded instead of MediaHttpUploader#getProgress:


 public static class MyUploadProgressListener implements MediaHttpUploaderProgressListener {

   public void progressChanged(MediaHttpUploader uploader) throws IOException {
     switch (uploader.getUploadState()) {
       case INITIATION_STARTED:
         System.out.println("Initiation Started");
         break;
       case INITIATION_COMPLETE:
         System.out.println("Initiation Completed");
         break;
       case MEDIA_IN_PROGRESS:
         System.out.println("Upload in progress");
         System.out.println("Upload percentage: " + uploader.getProgress());
         break;
       case MEDIA_COMPLETE:
         System.out.println("Upload Completed!");
         break;
      }
   }
 }
 

Methods

progressChanged(MediaHttpUploader uploader)

public abstract void progressChanged(MediaHttpUploader uploader)

Called to notify that progress has been changed.

This method is called once before and after the initiation request. For media uploads it is called multiple times depending on how many chunks are uploaded. Once the upload completes it is called one final time.

The upload state can be queried by calling MediaHttpUploader#getUploadState and the progress by calling MediaHttpUploader#getProgress.

Parameter
NameDescription
uploaderMediaHttpUploader

Media HTTP uploader

Exceptions
TypeDescription
IOException