This is a Flysystem adapter for the aws-sdk-php v3.
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/rankarpan/flysystem-aws-s3-v3"
}
],
"require": {
"league/flysystem-aws-s3-v3": "dev-cloudfront-v1.x"
}
}
composer require league/flysystem-aws-s3-v3:dev-cloudfront-v1.x
Using standard Aws\S3\S3Client
:
<?php
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
include __DIR__ . '/vendor/autoload.php';
$client = new S3Client([
'credentials' => [
'key' => 'your-key',
'secret' => 'your-secret'
],
'region' => 'your-region',
'version' => 'latest|version',
]);
$adapter = new AwsS3Adapter($client, 'your-bucket-name');
$filesystem = new Filesystem($adapter);
or using Aws\S3\S3MultiRegionClient
which does not require to specify the region
parameter:
<?php
use Aws\S3\S3MultiRegionClient;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
include __DIR__ . '/vendor/autoload.php';
$client = new S3MultiRegionClient([
'credentials' => [
'key' => 'your-key',
'secret' => 'your-secret'
],
'version' => 'latest|version',
]);
$adapter = new AwsS3Adapter($client, 'your-bucket-name');
$filesystem = new Filesystem($adapter);
'options' => [
'endpoint' => 'https://xxxxxxxxxxx.cloudfront.net',
'private_key' => 'private_key',
'key_pair_id' => 'key_pair_id',
]
$filesystem->getCloudFrontUrl('file.txt', new DateTime('+ 3 days'));
$filesystem->getTemporaryUrl('file.txt', new DateTime('+ 3 days'));