简体   繁体   中英

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM