我正在尝试在我的Laravel应用程序中编写一个函数,该函数将重命名S3驱动器上的文件。
我试过了:
if(Storage::disk('s3')->exists($old_path)) {
Storage::disk('s3')->move($old_path, $new_path);
}但它什么也做不了。
dd(Storage::disk('s3')->exists($old_path)) 返回True
也是
Storage::disk('s3')->put($full_path, file_get_contents($file));
Storage::disk('s3')->get($full_path);两者都能正常工作!
发布于 2021-05-14 22:26:43
问题出在我的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/*"
}https://stackoverflow.com/questions/67534473
复制相似问题