我打算使用Amazon S3让用户从iPhone上传照片,然后让他们公开观看。
我在了解如何在存储分区策略中设置这些安全性约束时遇到一些麻烦:
答案 0 :(得分:8)
好的,我最终还是解决了这个问题。唯一的事情是您无法在添加文件和更新文件时设置不同的权限。它们都被s3:PutObject所覆盖。此外,似乎无法限制文件大小。
{
"Version": "2008-10-17",
"Id": "policy",
"Statement": [
{
"Sid": "allow-public-read",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket/*"
},
{
"Sid": "allow-public-put",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::bucket/*"
}
]
}
答案 1 :(得分:0)
也许下面的内容可行,但我不确定您是否可以限制上传大小。
{
"Statement": [
{
"Effect": "Allow",
"Principal":"*",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:GetObjectAcl",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::mybucket/*",
"Condition": {}
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketAcl"
],
"Resource": "arn:aws:s3:::mybucket",
"Condition": {}
}
]
}