AWS S3 复制对象源密钥和目标密钥

AWS S3 copy object source key and destination key

我正在编写 JAVA 代码以在 AWS S3 中复制对象。

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

什么是源密钥和目标密钥?我读了很多理论书,但没有提到我们可以从哪里获得这些密钥。也许我漏掉了一部分。

请帮我获取存储桶的源键和目标键.... 也请为此提供示例...

来自documentation

CopyObjectRequest(java.lang.String sourceBucketName, java.lang.String sourceKey, java.lang.String destinationBucketName, java.lang.String destinationKey)
Constructs with basic options.

"sourceKey" 和 "destinationKey" 是您要复制的 S3 对象的键。 "sourceKey" 是现有对象的键,"destinationKey" 是要用于源对象副本的键名。

要在同一存储桶中复制对象:

CopyObjectRequest copyObjRequest = new CopyObjectRequest("myBucket", "myObject.txt", "myBucket", "myNewObject.txt");              
s3Client.copyObject(copyObjRequest);

要在不同的存储桶中复制对象:

CopyObjectRequest copyObjRequest = new CopyObjectRequest("myBucket", "myObject.txt", "myOtherBucket", "myNewObject.txt");              
s3Client.copyObject(copyObjRequest);

进一步阅读: