我正在编写JAVA代码来复制AWS S3中的对象。
CopyObjectRequest copyObjRequest = new CopyObjectRequest(srcbucket, srcKey, destbucket, destKey);
s3Client.copyObject(copyObjRequest);
什么是源密钥和目标密钥?我在理论上阅读了很多,但没有提到我们可以从哪里获得这些密钥。也许我错过了一些部分。
请帮助我获取水桶的源和目的地钥匙.... 请举例说明......
答案 0 :(得分:3)
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"是要用于源对象副本的keyName。
要在同一个存储桶中制作对象的副本:
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);
进一步阅读: