【问题标题】:AWS S3 copy object source key and destination keyAWS S3 复制对象源键和目标键
【发布时间】:2015-11-18 14:33:13
【问题描述】:

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

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

什么是源键和目的键?我在理论上读了很多,但没有提到我们可以从哪里获得这些密钥。也许我错过了一些部分。

请帮我获取存储桶的源键和目标键.... 请提供一个例子...

【问题讨论】:

    标签: java amazon-web-services amazon-s3 aws-sdk


    【解决方案1】:

    来自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);
    

    进一步阅读:

    【讨论】:

    • 如果我用外行语言说 sourcekey 是应该复制到目标存储桶上的源文件名?
    • @Ajay 正确。组合的“sourceBucketName”和“sourceKey”将描述您希望在 S3 中复制的对象的完整位置。
    猜你喜欢
    • 2017-01-01
    • 2022-10-15
    • 2019-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-05
    • 1970-01-01
    相关资源
    最近更新 更多