S3 Flysystem返回文件密钥,但size方法抛出“Not Found”

问题描述 投票:0回答:1

我可以使用league \ flysystem存储方法获取并列出S3中特定键/目录的文件:

$s3 = \Storage::disk('s3');
$files = $s3->files($cp->s3DirectoryPrefix);

收益:

array( 0 => "content_properties/503a3468-d660-44f8-9edd-f10cd812f346/submaster_primary.mp4")

但是,当我尝试获取返回的文件的大小时,它会抛出异常。

$size = $s3->size($files[0]);
League \ Flysystem \ FileNotFoundException
File not found at path: content_properties/503a3468-d660-44f8-9edd-f10cd812f346/submaster_primary.mp4

这仅发生在某个桶上。其他存储桶不抛出异常,并正确返回对象/文件的大小。

我知道我做错了什么?水桶上的某些设置?

通过CLI使用相同的凭据访问对象可以正常工作:

aws s3api head-object --bucket content-data-app-private --key content_properties/503a3468-d660-44f8-9edd-f10cd812f346/submaster_primary.mp4

aws s3api get-object --bucket content-data-app-private --key content_properties/503a3468-d660-44f8-9edd-f10cd812f346/submaster_primary.mp4 ~/Downloads/submaster_primary.mp4

这些返回正确的信息/内容。那么在Flysystem中发生了什么,它可以检索文件列表,但不能检索文件/对象本身的方法?

php laravel amazon-s3
1个回答
-1
投票

我不知道这是否适用于s3,所以你可以试试

    $datas = collect(Storage::disk('s3')->files($cp->s3DirectoryPrefix))
                        ->mapWithKeys(function($file) {
                            return [$file => Storage::disk('s3')->size($file)];
                        });
© www.soinside.com 2019 - 2024. All rights reserved.