Justinas
Justinas

Reputation: 43479

AWS get object from one bucket and place it in another bucket

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

Upvotes: 0

Views: 131

Answers (1)

Jeremy Lindblom
Jeremy Lindblom

Reputation: 6517

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.

Upvotes: 1

Related Questions