Path: blob/master/doc_source/CopyingObjctsUsingLLJavaMPUapi.md
4080 views
Copy an object using the AWS SDK for Java multipart upload API
To copy an Amazon S3 object that is larger than 5 GB with the AWS SDK for Java, use the low-level Java API . For objects smaller than 5 GB, use the single-operation copy described in Copy an Object Using the AWS SDK for Java.
To copy an object using the low-level Java API, do the following:
Initiate a multipart upload by executing the
AmazonS3Client.initiateMultipartUpload()method.Save the upload ID from the response object that the
AmazonS3Client.initiateMultipartUpload()method returns. You provide this upload ID for each part-upload operation.Copy all of the parts. For each part that you need to copy, create a new instance of the
CopyPartRequestclass. Provide the part information, including the source and destination bucket names, source and destination object keys, upload ID, locations of the first and last bytes of the part, and part number.Save the responses of the
AmazonS3Client.copyPart()method calls. Each response includes theETagvalue and part number for the uploaded part. You need this information to complete the multipart upload.Call the
AmazonS3Client.completeMultipartUpload()method to complete the copy operation.
Example The following example shows how to use the Amazon S3 low-level Java API to perform a multipart copy. For instructions on creating and testing a working sample, see Testing the Amazon S3 Java Code Examples.