我在尝试在 AWS S3 上使用 Flysystem 创建目录时遇到了一些困难 - 我不断收到 AccessDenied 响应。我的存储桶具有所有公共访问权限 blocked,但存储桶策略允许发送请求的用户对其执行所有操作:
{
"Version": "2008-10-17",
"Id": "PolicyForCloudFrontPrivateContent",
"Statement": [
{
"Sid": "AllowCloudFrontServicePrincipal",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-local-bucket/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::***:distribution/***"
}
}
},
{
"Sid": "2",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::***:user/local"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-local-bucket/*"
}
]
}
还有我的 local 用户策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:*",
"s3-object-lambda:*"
],
"Resource": "*"
}
]
}
我可以上传文件绝对没问题 - 只是目录,例如 images/blog 等,我收到 LeagueFlysystemUnableToWriteFile::atLocation 异常并抛出以下错误:
Error executing "PutObject" on "https://s3.eu-west-2.amazonaws.com/my-local-bucket/images/blog/"; AWS HTTP error: Client error: `PUT https://s3.eu-west-2.amazonaws.com/my-local-bucket/images/blog/` resulted in a `403 Forbidden` response: <?xml version="1.0" encoding="UTF-8"?> <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>***(truncated...) AccessDenied (client): Access Denied - <?xml version="1.0" encoding="UTF-8"?> <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>***</RequestId><HostId>***</HostId></Error>
知道是什么原因造成的吗?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
经过几周的尝试寻找答案,我发现如果我在创建 s3 驱动程序时将
visibility作为private并通过配置传递,那么它确实可以正常工作预计。