我正在尝试在 Laravel 应用程序中编写一个函数来重命名 S3 驱动器上的文件。
我努力了:
if(Storage::disk('s3')->exists($old_path)) {
Storage::disk('s3')->move($old_path, $new_path);
}
Run Code Online (Sandbox Code Playgroud)
但它没有做任何事情。
dd(Storage::disk('s3')->exists($old_path))
Run Code Online (Sandbox Code Playgroud)
回报True
还
Storage::disk('s3')->put($full_path, file_get_contents($file));
Storage::disk('s3')->get($full_path);
Run Code Online (Sandbox Code Playgroud)
两者都工作正常!
问题在于我的 S3 存储桶中的资源所允许的策略。
为了解决这个问题,我必须允许执行以下操作:
s3:GetObjectVersion
s3:DeleteObjectVersion
s3:PutObjectAcl
s3:GetObjectAcl
所以我的政策现在看起来像这样:
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:PutObject",
"s3:PutObjectAcl",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectVersion",
"s3:DeleteObject",
"s3:DeleteObjectVersion"
],
"Resource": "arn:aws:s3:::folder/path/*"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1692 次 |
| 最近记录: |