AsyncAws S3 Adapter

Interacting with Aws S3 through Flysystem can be done by using the League\Flysystem\AsyncAwsS3\AsyncAwsS3Adapter.

Read more about AsyncAws’s S3Client in their documentation.

Simple usage:

$client = new AsyncAws\S3\S3Client();

// The internal adapter
$adapter = new League\Flysystem\AsyncAwsS3\AsyncAwsS3Adapter(
    // S3Client
    $client,
    // Bucket name
    'bucket-name'
);

// The FilesystemOperator
$filesystem = new League\Flysystem\Filesystem($adapter);

Advanced usage:

$client = new AsyncAws\S3\S3Client();

// The internal adapter
$adapter = new League\Flysystem\AwsS3V3\AwsS3V3Filesystem(
    // S3Client
    $client,
    // Bucket name
    'bucket-name',
    // Optional path prefix
    'path/prefix',
    // Visibility converter (League\Flysystem\AwsS3V3\VisibilityConverter)
    new League\Flysystem\AwsS3V3\PortableVisibilityConverter(
        // Optional default for directories
        League\Flysystem\Visibility::PUBLIC // or ::PRIVATE
    )
);

// The FilesystemOperator
$filesystem = new League\Flysystem\Filesystem($adapter);

Support for large files:

If you want to upload files larger than 5GB you need to use the SimpleS3Client. The SimpleS3Client automatically switches to MultipartUpload for large files. It also supports a user friendly interface to upload(), download(), getUrl() etc if you happen to use the client without Flysystem.

composer require async-aws/simple-s3
$client = new AsyncAws\SimpleS3\SimpleS3Client();
$adapter = new League\Flysystem\AsyncAwsS3\AsyncAwsS3Adapter($client, 'bucket-name');
$filesystem = new League\Flysystem\Filesystem($adapter);