Laravel S3 适配器无效参数错误

Laravel S3 Adapter Invalid Argument Error

我正在尝试将媒体文件上传到 Digital Ocean。这是我的代码:

<?php

namespace App\Jobs;

use App\Entities\Media;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Storage;

class UploadMediaToCloud implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $media;

    /**
     * UploadMediaToCloud constructor.
     *
     * @param Media $media
     */
    public function __construct(Media $media)
    {
        $this->media = $media;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $photoPath = $this->media->path . '/' . $this->media->name . '.' . $this->media->extension;
        $photoFullPath = env('APP_URL') . '/' . $photoPath;

        Storage::disk('spaces')->put($photoPath, file_get_contents($photoFullPath), 'public');

        $this->media->disk = 'spaces';
        $this->media->updated_at = Carbon::now();
        $this->media->save();
    }
}

在我的 'filesystems.php' 配置文件中:

'spaces' => [
        'driver' => 's3',
        'key' => env('DO_SPACES_KEY'),
        'secret' => env('DO_SPACES_SECRET'),
        'endpoint' => env('DO_SPACES_ENDPOINT', 'https://ams3.digitaloceanspaces.com'),
        'region' => env('DO_SPACES_REGION', 'ams3'),
        'bucket' => env('DO_SPACES_BUCKET')
    ]

此作业进程在本地环境中完美运行。 (我的 .env 文件与 prod 完全相同)但是正在抛出:

InvalidArgumentException
Missing required client configuration options: 

region: (string)

A "region" configuration value is required for the "s3" service
(e.g., "us-west-2"). A list of available public regions and 
endpoints can be
found at http://docs.aws.amazon.com/general/latest/gr/rande.html.

这个异常。我已经尝试对所有凭据进行硬编码,但到目前为止没有任何效果。

当您在生产环境中更新 .env 时,请务必重新加载您的配置。这可以通过 运行 php artisan config:clear 然后 php artisan config:cache

来完成

遇到此问题的任何人,请尝试更新服务器上的 Linux 软件包。我相信 AWS SDK 存在一些向后兼容性问题。更新解决方案对我有用。