league/flysystem-async-aws-s3
Flysystem adapter for Amazon S3 using AsyncAws. Install via composer to integrate S3 storage with Flysystem’s filesystem abstraction for uploads, reads, writes, and directory operations. Part of the Flysystem sub-split; docs available online.
Install the package via Composer:
composer require league/flysystem-async-aws-s3
Then, create an AsyncAws\S3\S3Client instance (using AsyncAws directly) and wrap it with Flysystem’s adapter:
use AsyncAws\S3\S3Client;
use League\Flysystem\AsyncAwsS3\AsyncAwsS3Adapter;
use League\Flysystem\Filesystem;
$s3Client = new S3Client([
'endpoint' => 'https://s3.amazonaws.com',
'region' => 'us-east-1',
'credentials' => [
'key' => 'your-key',
'secret' => 'your-secret',
],
]);
$adapter = new AsyncAwsS3Adapter($s3Client, 'your-bucket-name');
$filesystem = new Filesystem($adapter);
Start by testing basic operations like write(), read(), and has() to confirm connectivity.
config/filesystems.php by extending the S3 driver and injecting the AsyncAwsS3Adapter manually, since this adapter is not included in Laravel’s core S3 driver. Use a custom service provider to wire S3Client → AsyncAwsS3Adapter → Filesystem.ParallelAsyncExecutor or custom concurrency logic.readStream()/writeStream() for large files—AsyncAws streams data efficiently without loading into memory.ChecksumValidationMiddleware) to ensure integrity for critical uploads, especially when syncing to other stores.league/flysystem-aws-s3-v3 is widely used, but this package requires manual adapter wiring—no built-in aws-s3-async driver.aws s3api head-bucket parity.HeadObject or GetObject, not ListObjects. Use ->listContents()->map(fn ($file) => $filesystem->getVisibility($file['path'])) to enrich listing with visibility info if needed.S3Exception) expose raw HTTP details—catch AwsException and log getStatusCode()/getErrorCode() for actionable debugging.How can I help you explore Laravel packages today?