AWS S3复制对象源密钥和目标密钥 [英] AWS S3 copy object source key and destination key

查看:172
本文介绍了AWS S3复制对象源密钥和目标密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am writing JAVA code to copy object within AWS S3.

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

什么是源密钥和目标密钥?我从理论上学到了很多东西,但是没有提到从哪里可以得到这些密钥.也许我错过了一部分.

What is source key and destination key? I read a lot in theory but no where it is mentioned that from where we can get these keys. Maybe I missed some part.

请帮助我获取存储桶的源密钥和目标密钥. 请为此提供一个示例...

Please help me to get source and destination keys of bucket.... Please provide an example for that also...

推荐答案

来自"sourceKey"和"destinationKey"是您要复制的S3对象的键. "sourceKey"是现有对象的键,而"destinationKey"是要用于复制源对象的键名.

The "sourceKey" and "destinationKey" are the keys of the S3 Objects you are looking to copy. The "sourceKey" is the key of the existing object, and the "destinationKey" is the keyName you want to use for the copy of the source object.

要在同一存储桶中复制对象,请执行以下操作:

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

进一步阅读:

  • S3 Documentation - Object Keys and Metadata
  • S3 Documentation - Working with Amazon S3 Objects

这篇关于AWS S3复制对象源密钥和目标密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆