I'm having an issue with Laravel 5's filesystem when uploading files to an S3 bucket. The line that is running to the filesystem is:
Storage::disk('s3')->put($slug, $img);
It works as it should for:
Storage::disk('local')->put($slug, $img);
But when I change the disk to S3 it throws the following error:
Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found
As per the L5 docs, I have the following requirement in my composer.json
"league/flysystem-aws-s3-v2": "~1.0"
which installed league's aws flysystem adapter under:
League\flysystem-aws-s3-v2\
I have tried updating the path in the fileSystemManager.php in the filesystem vendor folder to the aws flysystem installation path but it still doesn't work. I can't seem to find anyone else who has experienced this behaviour.
A fresh pair of eyes or a knowledgeable head who might know more about Laravel than I would be great. I really can't seem to the issue.
UPDATE
I did a fresh install of the aws flysystem and not I get the following:
ErrorException in Util.php line 250:
fstat() expects parameter 1 to be resource, object given
Ok so I fixed the initial issue by removing aws/aws-sdk-php : "^2.8.*
that I had in my composer.json
and ran a fresh 'composer require league/flysystem-aws-s3-v3 ~1.0'. This fixed the initial error in finding the S3 flysystem.
The second error fstat() expects parameter 1 to be resource, object given
related to my attempt to pass an image object to the put method:
Storage::disk('s3')->put($slug, $img);
when it expects a string. This was fixed by stringifying the $img object
Storage::disk('s3')->put($slug, $img->__toString());
Hope this helps somebody else who might encounter this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With