Use Amazon S3 Multi-Region Access Points with the
AWS SDK for PHP Version 3
Amazon Simple Storage Service (S3) Multi-Region Access Points provide a global endpoint for routing Amazon S3 request traffic between AWS Regions.
You can create Multi-Region Access Points using the SDK for PHP, another AWS SDK, the S3 console, or AWS CLI,
Important
To use Multi-Region Access Points with the SDK for PHP, your PHP environment must have the AWS Common Runtime (AWS CRT) extension installed.
When you create a Multi-Region Access Point, Amazon S3 generates an Amazon Resource Name (ARN) that has the following format:
arn:aws:s3::
account-id
:accesspoint/MultiRegionAccessPoint_alias
You can use the generated ARN in place of a bucket name for getObject()
and
putObject()
methods.
<?php
require './vendor/autoload.php';
use Aws\S3\S3Client;
// Assign the Multi-Region Access Point to a variable and use it place of a bucket name.
$mrap = 'arn:aws:s3::123456789012:accesspoint/mfzwi23gnjvgw.mrap';
$key = 'my-key';
$s3Client = new S3Client([
'region' => 'us-east-1'
]);
$s3Client->putObject([
'Bucket' => $mrap,
'Key' => $key,
'Body' => 'Hello World!'
]);
$result = $s3Client->getObject([
'Bucket' => $mrap,
'Key' => $key
]);
echo $result['Body'] . "\n";
// Clean up.
$result = $s3Client->deleteObject([
'Bucket' => $mrap,
'Key' => $key
]);
$s3Client->waitUntil('ObjectNotExists', ['Bucket' => $mrap, 'Key' => $key]);
echo "Object deleted\n";