【问题标题】:League\\Flysystem\\AwsS3v3\\AwsS3Adapter::__construct(): Argument #1 ($client) must be of type Aws\\S3Client, Aws\\S3\\S3Client givenLeague\\Flysystem\\AwsS3v3\\AwsS3Adapter::__construct():参数 #1 ($client) 必须是 Aws\\S3Client 类型,Aws\\S3\\S3Client 给定
【发布时间】:2022-01-10 10:28:36
【问题描述】:

我已经通过在我的 Laravel 8 项目中运行以下 composer 命令安装了 s3 flysystem 包

composer require --with-all-dependencies league/flysystem-aws-s3-v3 "^1.0"

并尝试将请求中的文件存储为

$imageName = $request->file('file')->store('uploads');

我收到以下错误

League\Flysystem\AwsS3v3\AwsS3Adapter::__construct():参数 #1 ($client) 必须是 Aws\S3Client 类型,Aws\S3\S3Client 给定,称为 在 D:\Projects\Rescale\vendor\laravel\framework\src\Illuminate\Filesystem\FilesystemManager.php 在第 229 行

【问题讨论】:

    标签: laravel amazon-web-services amazon-s3 laravel-8 laravel-filesystem


    【解决方案1】:

    所以似乎 ThePHPLeague Flysystem 主要版本已更新(到 v2),因此破坏了很多东西,因为最新的 Laravel 依赖于“^1.1”(参见:https://github.com/laravel/framework/blob/8.x/composer.json#L27)。

    我遇到了这个错误,所以我的解决方法是改用特定版本。


    1. 转到 composer.json 并使用最新的 v1(请参阅:https://github.com/thephpleague/flysystem-aws-s3-v3/tags)。
    - "league/flysystem-aws-s3-v3": "^1.0",
    + "league/flysystem-aws-s3-v3": "1.0.29",
    
    1. 运行 composer update 并让 composer 更新您的依赖项。

    【讨论】:

      【解决方案2】:

      试试这个在 AWS 上上传图片

      $path = Storage::disk('s3')->put('uploads', $request->file('file'));
      

      【讨论】:

        猜你喜欢
        • 2022-10-24
        • 2018-01-19
        • 2020-09-02
        • 2021-05-11
        • 2020-09-02
        • 2021-01-19
        • 2021-06-28
        • 2020-12-22
        • 1970-01-01
        相关资源
        最近更新 更多