无法使用laravel 5.7在s3存储桶中上传文件-参数1传递给League \ Flysystem \ AwsS3v3 \ AwsS3Adapter: [英] Unable to upload file in s3 bucket using laravel 5.7- Argument 1 passed to League\Flysystem\AwsS3v3\AwsS3Adapter:

查看:114
本文介绍了无法使用laravel 5.7在s3存储桶中上传文件-参数1传递给League \ Flysystem \ AwsS3v3 \ AwsS3Adapter:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将图像上传到s3存储桶,但无法这样做.得到以下错误:

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)

我的composer.json包含:

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",
...

我的filesystems.php

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用户权限-AmazonS3FullAccess

AWS s3 user permission - AmazonS3FullAccess

AWS s3存储桶-政策

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]/*"
        }
    ]
}

任何帮助将不胜感激.

谢谢

推荐答案

经过4天的苦苦挣扎,我删除了两者"aws/aws-sdk-php":"3.0" "league/flysystem-aws-s3-v3":〜1.0",来自composer.json的"League/flysystem-cached-adapter":"1.0" ,并运行 composer require League/flysystem-aws-s3-v3

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 :)

这篇关于无法使用laravel 5.7在s3存储桶中上传文件-参数1传递给League \ Flysystem \ AwsS3v3 \ AwsS3Adapter:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆