Reputation: 2477
I am trying to upload the image to the s3 bucket but unable to do so. Getting the following error:
Storage::disk('s3')->put($filename, file_get_contents($file));
Argument 1 passed to League\Flysystem\AwsS3v3\AwsS3Adapter::__construct() must be an instance of Aws\S3\S3ClientInterface, instance of Aws\S3\S3Client given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php on line 208 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Argument 1 passed to League\\Flysystem\\AwsS3v3\\AwsS3Adapter::__construct() must be an instance of Aws\\S3\\S3ClientInterface, instance of Aws\\S3\\S3Client given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php on line 208 at /var/www/html/vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php:85)
My composer.json contains:
...
"aws/aws-sdk-php": "3.0",
"laravel/framework": "5.7.*",
"league/flysystem-aws-s3-v3": "~1.0",
"league/flysystem-cached-adapter": "1.0",
...
My filesystems.php:
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
AWS s3 user permission - AmazonS3FullAccess
AWS s3 bucket - policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:GetObjectVersion",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::[bucket-name]/*"
}
]
}
Upvotes: 3
Views: 7423
Reputation: 609
The solution for me was to update two lines in this file - /vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php
OLD:
use Aws\S3Client;
use Aws\S3ClientInterface;
NEW:
use Aws\S3\S3Client;
use Aws\S3\S3ClientInterface;
Upvotes: -1
Reputation: 3015
I faced the issue on Laravel 5.8, local and AWS s3 bucket was failed to create the resource and laravel backups.
please run this command, that will fix it.
composer require league/flysystem-aws-s3-v3:~1.0
Upvotes: 3
Reputation: 2477
After struggling for more than 4 days, I removed both
"aws/aws-sdk-php": "3.0"
, and "league/flysystem-aws-s3-v3": "~1.0", "league/flysystem-cached-adapter": "1.0",
from composer.json and run composer require league/flysystem-aws-s3-v3
After that, it worked :)
Upvotes: 1