This might help even if the thread is about Laravel 5.7
Nov 27, 2021
13
Level 8
Flysystem Argument #1 ($client) must be of type Aws\S3Client
I'm using league/flysystem-aws-s3-v3 ^1.0 package to upload my images on DigitalOcean Spaces and I got the error below when I try to trigger the upload.
League\Flysystem\AwsS3v3\AwsS3Adapter::__construct(): Argument #1 ($client) must be of type Aws\S3Client, Aws\S3\S3Client given, called in /home/forge/site.com/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php on line 229
composer.json
"laravel/framework": "^8.65",
"league/flysystem-aws-s3-v3": "1.0",
.env
SPACES_ACCESS_KEY_ID=xxxxx
SPACES_SECRET_ACCESS_KEY=xxxxxxx
SPACES_DEFAULT_REGION=sgp1
SPACES_BUCKET=avatar
SPACES_ENDPOINT=sgp1.digitaloceanspaces.com
SPACES_PUBLIC=https://xxx-xxx.sgp1.digitaloceanspaces.com
filesystems.php
'spaces' => [
'driver' => 's3',
'key' => env('SPACES_ACCESS_KEY_ID'),
'secret' => env('SPACES_SECRET_ACCESS_KEY'),
'region' => env('SPACES_DEFAULT_REGION'),
'bucket' => env('SPACES_BUCKET'),
'url' => env('SPACES_PUBLIC'),
'endpoint' => env('SPACES_ENDPOINT'),
'bucket_endpoint' => true,
'visibility' => 'public',
],
Controller
use Illuminate\Support\Facades\Storage;
$user = Auth::user();
$filePath = Storage::disk('spaces')
->putFile('avatars/user-'.$user->id, $request->image, 'public');
$user->avatar = env('SPACES_PUBLIC').$filePath;
$user->save();
Level 74
1 like
Please or to participate in this conversation.