chandra shekhar
chandra shekhar

Reputation: 11

aws s3 bucket copying files between buckets

Can some one please explain the parameters in the CopyObjectRequest constructor:

CopyObjectRequest copyObjRequest = new CopyObjectRequest(srcbucket, srcKey, destbucket, destKey);              
s3Client.copyObject(copyObjRequest);

What does sourcekey and destinationkey refer to, and what they should hold?

Upvotes: 1

Views: 1728

Answers (1)

Anthony Neace
Anthony Neace

Reputation: 26031

Per the Java SDK documentation for CopyObjectRequest:

Constructor definition:

public CopyObjectRequest(java.lang.String sourceBucketName,
                 java.lang.String sourceKey,
                 java.lang.String destinationBucketName,
                 java.lang.String destinationKey)

Constructor Parameters:

sourceBucketName - The name of the S3 bucket containing the object to copy.

sourceKey - The source bucket key under which the object to copy is stored.

destinationBucketName - The name of the S3 bucket to which the new object will be copied.

destinationKey - The destination bucket key under which the new object will be copied.

In Amazon S3, a "key" is a unique identifier that you can assign to objects in your bucket. Basically, it is a string -- a name for your bucket objects.

So in this context, the 'SourceKey' would be the unique identifier of an already existing object that you want to copy, and the 'DestinationKey' would be the unique identifier that you want to assign to the newly copied object.

Further reading on Amazon S3 keys is available in their documentation concerning Amazon S3 Concepts.

Upvotes: 1

Related Questions