0

I'm trying to upload an image file to AWS_BUCKET. Here is my controller function,

public function createImage(Request $request)
{
   $path = $request->file('image')->store('images', 's3');
}

when I'm trying to upload an image using postman below error appears

Argument 1 passed to League\\Flysystem\\AwsS3v3\\AwsS3Adapter::__construct() must be an instance of Aws\\S3Client, instance of Aws\\S3\\S3Client given, 
called in C:\\xampp\\htdocs\\project-api\\vendor\\laravel\\framework\\src\\Illuminate\\Filesystem\\FilesystemManager.php on line 229

I tried several solutions. Nothing worked. Does anyone know how to solve this.? Is there an error with my code.?

Tharindu Marapana
  • 225
  • 1
  • 5
  • 13
  • what your version of `league/flysystem-aws-s3-v3` in `composer.json`? – Lee Feb 22 '22 at 07:57
  • Please try to use `"league/flysystem-aws-s3-v3": "~1.0"` `$name = $request->image_path; $file_name = $makeUniqueName . '.' . $request->file($name)->getClientOriginalExtension(); //Store s3 bucket $upload= Storage::disk('s3')->put('uploads_folder/folder_name', $request->file($name));` – Saimun Hossain Feb 22 '22 at 08:02
  • what version of Laravel is this? – apokryfos Feb 22 '22 at 08:03
  • @Lee league/flysystem-aws-s3-v3 version 1.0 – Tharindu Marapana Feb 22 '22 at 08:27
  • @apokryfos Laravel 8 – Tharindu Marapana Feb 22 '22 at 08:27
  • @SaimunHossain it did not work... Is there any other way or source.? – Tharindu Marapana Feb 22 '22 at 08:28
  • @TharinduMarapana try this time: `use Illuminate\Support\Facades\Storage;` `$contentFile = null; $disk = Storage::disk('s3'); if($request->hasFile('image_url')){ $file_name = uniqid() .'.'. $request->file('image_url')->getClientOriginalExtension(); $path = 'folderName/'. $file_name; $disk->putFileAs('folderName', $request->file('image_url'), $file_name,'public'); $contentFile = $path; }` _make sure all credentials and other stuff are okay_ – Saimun Hossain Feb 22 '22 at 08:35
  • @SaimunHossain thanks much for your effort. I found the issue. There was a version problem with my "league/flysystem-aws-s3-v3". It should be updated to version "1.0.29" Then now it works fine. Thanks again. – Tharindu Marapana Feb 22 '22 at 09:06

0 Answers0