AWS从一个存储桶获取对象并将其放在另一个存储桶中

AWS从一个存储桶获取对象并将其放在另一个存储桶中

问题描述:

i'm trying to get object from one AWS account S3 to another account S3. Currently i make that functionality with temporary directory like so:

$s3_remote = S3Client::factory(/*AWS logins*/);
$s3_local = S3Client::factory(/*AWS logins*/);

$s3_remote->getObject([
     "Bucket" => $bucket,
     "Key" => $object,
     "SaveAs" => $path . $name . "." . $extension,
]);

$s3_local->putObject([
     "Bucket" => $bucket,
     "Key" => $object,
     "SourceFile" => $path . $name . "." . $extension,
]);

Is there any way to getObject directly to local S3 bucket from remote-one?

Is there something like:

$s3_remote->getObject(
    "Bucket" => $bucket,
    "Key" => $key
    "LocalAWSKey" => "13265ASD",
    "LocalAWSSKey" => "aASd31a2sd13as564fsdg4aA"
);

You can setup permissions to allow one account access to another account's S3 resources. See the Access Control section of the S3 Developer Guide. Once the appropriate permissions are in place, you should be able to use the S3Client::copyObject() method.