Search in sources :

Example 11 with TransferProgress

use of com.amazonaws.services.s3.transfer.TransferProgress in project aws-doc-sdk-examples by awsdocs.

the class XferMgrProgress method showTransferProgress.

// Prints progress while waiting for the transfer to finish.
public static void showTransferProgress(Transfer xfer) {
    // snippet-start:[s3.java1.s3_xfer_mgr_progress.poll]
    // print the transfer's human-readable description
    System.out.println(xfer.getDescription());
    // print an empty progress bar...
    printProgressBar(0.0);
    // update the progress bar while the xfer is ongoing.
    do {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            return;
        }
        // Note: so_far and total aren't used, they're just for
        // documentation purposes.
        TransferProgress progress = xfer.getProgress();
        long so_far = progress.getBytesTransferred();
        long total = progress.getTotalBytesToTransfer();
        double pct = progress.getPercentTransferred();
        eraseProgressBar();
        printProgressBar(pct);
    } while (xfer.isDone() == false);
    // print the final state of the transfer.
    TransferState xfer_state = xfer.getState();
    System.out.println(": " + xfer_state);
// snippet-end:[s3.java1.s3_xfer_mgr_progress.poll]
}
Also used : TransferState(com.amazonaws.services.s3.transfer.Transfer.TransferState)

Aggregations

TransferProgress (com.amazonaws.services.s3.transfer.TransferProgress)9 IOException (java.io.IOException)4 AmazonClientException (com.amazonaws.AmazonClientException)3 AmazonServiceException (com.amazonaws.AmazonServiceException)3 Copy (com.amazonaws.services.s3.transfer.Copy)3 TransferState (com.amazonaws.services.s3.transfer.Transfer.TransferState)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 AmazonS3Exception (com.amazonaws.services.s3.model.AmazonS3Exception)2 GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)2 MultiObjectDeleteException (com.amazonaws.services.s3.model.MultiObjectDeleteException)2 MultipartUpload (com.amazonaws.services.s3.model.MultipartUpload)2 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)2 MultipleFileDownload (com.amazonaws.services.s3.transfer.MultipleFileDownload)2 MultipleFileUpload (com.amazonaws.services.s3.transfer.MultipleFileUpload)2 Upload (com.amazonaws.services.s3.transfer.Upload)2 DownloadImpl (com.amazonaws.services.s3.transfer.internal.DownloadImpl)2 MultipleFileDownloadImpl (com.amazonaws.services.s3.transfer.internal.MultipleFileDownloadImpl)2 MultipleFileUploadImpl (com.amazonaws.services.s3.transfer.internal.MultipleFileUploadImpl)2