Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

longestdrive's avatar

Storage S3 : must be an instance of Aws\S3Client

Hi I'm just trying to upgrade a 4.2 app to 5.1 and make use of the new Filesystem.

I'm having troule configuring and using the S3 driver - having looked at the video tut and the online Docs i'm struggling to get this to work.

At the moment my error is:

Argument 1 passed to League\Flysystem\AwsS3v3\AwsS3Adapter::__construct() must be an instance of Aws\S3Client, instance of Aws\S3\S3Client given

In composer I have installed the following package:

"league/flysystem-aws-s3-v3": "1.0",

I've seen references to this package https://github.com/GrahamCampbell/Laravel-Flysystem

but I'm not sure if I should install this one as well.

I have configured the config file with my credentials . The user has full access to the bucket

In my class I have a function which effectively uploads an image from the local storage to the s3 storage. I am initiating S3 as follows:

$s3 = Storage::disk('s3');

I have injected the following :

use Illuminate\Contracts\Filesystem\Filesystem;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use Storage;

I' very confused how to get this set up and working. Can someone help me in the right direction please.

What packages should I have installed? What should be in my config/app.php ? What do I need to inject?

Thank you

0 likes
3 replies
joedawson's avatar
Level 18

You won't need to install that package individually (the Graham Cambell one), also remove these.

use Illuminate\Contracts\Filesystem\Filesystem;
use League\Flysystem\AwsS3v3\AwsS3Adapter;

You don't need them as Storage will deal with that itself.

Also, update your composer to this:

"league/flysystem-aws-s3-v3": "~1.0"

(Notice the tilde) I'm not sure if it'll make a difference, but that's what I have and what the docs recommend.

Are you receiving your error when simply doing this?

$s3 = Storage::disk('s3');

Or are you doing anything else with that?

2 likes
longestdrive's avatar

That's fantastic - so frustrating as well but with the new package and correct version i'm now able to initiate the disk

THANK YOU!!

Please or to participate in this conversation.