程序包 com.sinacloud.scs.services.scs.transfer

Transfer management.

请参阅: 说明

程序包com.sinacloud.scs.services.scs.transfer的说明

Transfer management.

This package provides the com.sina.scs.transfer.TransferManager class, which manages a queue of asynchronous transfers. Callers can create a TransferManager instance, sharing that same instance throughout their application, queue new uploads for TransferManager to process, and continue working while TransferManager tracks the asynchronous upload progress.

The main benefits of using TransferManager are:

The AmazonS3TransferProgress sample included in the AWS SDK for Java demonstrates how to use TransferManager and how to track progress for uploads.

Using TransferManager to upload data to Amazon S3 is easy:

 AWSCredentials myCredentials = new BasicAWSCredentials(...);
 TransferManager tx = new TransferManager(myCredentials);
 Upload myUpload = tx.upload(myBucket, myFile.getName(), myFile);

 // You can poll your transfer's status to check its progress
 if (myUpload.isDone() == false) {
     System.out.println("Transfer: " + myUpload.getDescription());
     System.out.println("  - State: " + myUpload.getState());
     System.out.println("  - Progress: " + myUpload.getProgress().getBytesTransferred());
 }

 // Transfers also allow you to set a ProgressListener to receive
 // asynchronous notifications about your transfer's progress.
 myUpload.addProgressListener(myProgressListener);

 // Or you can block the current thread and wait for your transfer to
 // to complete.  If the transfer fails, this method will throw an
 // AmazonClientException or AmazonServiceException detailing the reason.
 myUpload.waitForCompletion();
 
另请参阅:
com.sina.scs.transfer.TransferManager

Copyright © 2016. All rights reserved.