Skip to content

Latest commit

 

History

History
119 lines (93 loc) · 2.54 KB

aws-s3-v3.md

File metadata and controls

119 lines (93 loc) · 2.54 KB
layout permalink redirect_from title
default
/docs/adapter/aws-s3/
/adapter/aws-s3/
/adapter/aws-s3-v2/
/adapter/aws-s3-v3/
Aws S3 Adapter V3

Installation

composer require league/flysystem-aws-s3-v3

Usage

use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;

$client = new S3Client([
    'credentials' => [
        'key'    => 'your-key',
        'secret' => 'your-secret',
    ],
    'region' => 'your-region',
    'version' => 'latest|version',
]);

$adapter = new AwsS3Adapter($client, 'your-bucket-name', 'optional/path/prefix');

$filesystem = new Filesystem($adapter);

The required IAM permissions are:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1420044805001",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:ReplicateObject",
                "s3:DeleteObject"                
            ],
            "Resource": [
                "arn:aws:s3:::your-bucket-name",
                "arn:aws:s3:::your-bucket-name/*"
            ]
        }
    ]
}

To enable reduced redunancy storage set up your adapter like so:

$adapter = new AwsS3Adapter($client, 'bucket-name', 'optional/path/prefix', [
    'StorageClass'  =>  'REDUCED_REDUNDANCY',
]);

Compatible storage protocols

If you're using a storage service which implements the S3 protocols, you can set the base_url configuration option when constructing the client.

$client = new S3Client([
    'base_url' => 'http://some.other.endpoint',
    // ... other settings
]);

🚨 Aws S3 Adapter - SDK V2 (LEGACY ADAPTER)

Installation

composer require league/flysystem-aws-s3-v2

Usage

use Aws\S3\S3Client;
use League\Flysystem\AwsS3v2\AwsS3Adapter;
use League\Flysystem\Filesystem;

$client = S3Client::factory([
    'key'    => '[your key]',
    'secret' => '[your secret]',
    'region' => '[aws-region]',
]);

$adapter = new AwsS3Adapter($client, 'bucket-name', 'optional/path/prefix');

$filesystem = new Filesystem($adapter);

To enable reduced redunancy storage set up your adapter like so:

$adapter = new AwsS3Adapter($client, 'bucket-name', 'optional/path/prefix', [
    'StorageClass'  =>  'REDUCED_REDUNDANCY',
]);