AWS Developer Tools Blog

Using Transfer Manager to Copy Amazon S3 Objects

The latest addition to the list of Transfer Manager features is the ability to easily make copies of your data in Amazon S3.

The new TransferManager.copy method allows you to easily copy an existing Amazon S3 object from one location to another.

Under the hood, TransferManager selects which copy algorithm is best for your data, either single-part copy or multipart copy. When possible, TransferManager initiates multipart copy requests in parallel, each copying a small part of the Amazon S3 object, resulting in better performance, throughput, and resilience to errors. You don’t have to worry about the details of copying your data – just rely on TransferManager's easy to use, asynchronous API for working with Amazon S3.

The following example shows how easy it is to copy data using TransferManager.

// Create a new transfer manager object with your credentials.

TransferManager tm = new TransferManager(new DefaultAWSCredentialsProviderChain());

// The copy method returns immediately as your data copies in the background.
// Use the returned transfer object to track the progress of the copy operation.

Copy copy = tm.copy(sourceBucket, sourceKey,
	              destinationBucket, destinationKey);

// Perform any work while the copy processes

if (copy.isDone()) {
   System.out.println("Copy operation completed.");
}

There’s lots more great functionality in TransferManager. Check out some of our other blog posts on TransferManager

Any new functionality that you’d like us to add to TransferManager? Let us know your ideas.