【发布时间】:2019-02-05 20:52:29
【问题描述】:
我能够使用 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 中发生了什么,它可以检索文件列表,但不能检索文件/对象本身的方法?
【问题讨论】:
-
你需要给出bucket的完整路径...“content_properties”是主要的“bucket”吗?
-
不是相关评论,因为适配器返回桶内对象的对象键。
-
“不是相关评论”,真的吗?任何 S3 PHP 适配器中的 size 函数都需要对象的完整路径,祝您好运。