我正在尝试将 S3 Multipart Uploader 从 Laravel 8 升级到 Laravel 9,并按照文档中的说明升级到 Flysystem 3,并且没有依赖错误https://laravel.com/docs/9.x/upgrade#flysystem-3 .
我无法访问底层 S3Client 来创建分段上传。
// Working in Laravel 8
// Laravel 9 throws exception on getAdapter()
$client = Storage::disk('s3')->getDriver()->getAdapter()->getClient();
// Underlying S3Client is used to create Multipart uploader as below
$bucket = config('filesystems.disks.s3.bucket');
$result = $client->createMultipartUpload([
'Bucket' => $bucket,
'Key' => $key,
'ContentType' => 'image/jpeg',
'ContentDisposition' => 'inline',
]);
return response()
->json([
'uploadId' => $result['UploadId'],
'key' => $result['Key'],
]);
然而,Laravel 9 会抛出异常Call to undefined method League\Flysystem\Filesystem::getAdapter()
。
我查看了 League\Flysystem 的源代码和 Laravel 的更新,但似乎无法找出使用更新和访问底层Aws\S3\S3Client
.
我更大的项目正在使用一个分叉的 laravel-uppy-s3-multipart-upload 库,可以在这里看到 https://github.com/kerkness/laravel-uppy-s3-multipart-upload/tree/laravel9