[英]How to copy S3 objects between regions with Amazon AWS PHP SDK?
I'm trying to copy Amazon AWS S3 objects between two buckets in two different regions with Amazon AWS PHP SDK v3. 我正在尝试使用Amazon AWS PHP SDK v3在两个不同区域的两个存储桶之间复制Amazon AWS S3对象。 This would be a one-time process, so I don't need
cross-region replication
. 这将是一次性过程,因此我不需要
cross-region replication
。 Tried to use copyObject()
but there is no way to specify the region. 试图使用
copyObject()
但没有办法指定区域。
$s3->copyObject(array(
'Bucket' => $targetBucket,
'Key' => $targetKeyname,
'CopySource' => "{$sourceBucket}/{$sourceKeyname}",
));
Source: http://docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjectUsingPHP.html 资料来源: http : //docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjectUsingPHP.html
You don't need to specify regions for that operation. 您无需为该操作指定区域。 It'll find out the target bucket's region and copy it.
它会找出目标桶的区域并复制它。
But you may be right, because on AWS CLI there is source region and target region attributes which do not exist on PHP SDK. 但您可能是对的,因为在AWS CLI上存在PHP SDK上不存在的源区域和目标区域属性。 So you can accomplish the task like this:
所以你可以完成这样的任务:
Or use just cli and use this single command: 或者只使用cli并使用以下单个命令:
aws s3 cp s3://my-source-bucket-in-us-west-2/ s3://my-target-bucket-in-us-east-1/ --recursive --source-region us-west-2 --region us-east-1
Different region bucket could also be different account. 不同的区域桶也可以是不同的帐户。 What others had been doing was to copy off from one bucket and save the data temporary locally, then upload to different bucket with different credentials.
其他人一直在做的是从一个存储桶复制并在本地临时保存数据,然后上传到具有不同凭据的不同存储桶。 (if you have two regional buckets with different credentials).
(如果您有两个具有不同凭据的区域存储桶)。
Newest update from CLI tool allows you to copy from bucket to bucket if it's under the same account. CLI工具的最新更新允许您从存储桶复制到存储桶,如果它在同一帐户下。 Using something like what Çağatay Gürtürk mentioned.
使用ÇağatayGürtürk提到的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.