【发布时间】:2017-10-14 15:04:06
【问题描述】:
我正在尝试设置一个 S3 存储桶以接受匿名上传,同时允许存储桶所有者拥有全部权限并阻止公共读取访问。按照here 的代码,我在下面设置了存储桶策略。我想使用 curl 上传到存储桶,但我得到的只是
访问被拒绝
这是存储桶策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "allow-anon-put",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::[mybucket]/uploads/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control"
}
}
},
{
"Sid": "deny-other-actions",
"Effect": "Deny",
"NotPrincipal": {
"AWS": "arn:aws:iam::[myid]:root"
},
"NotAction": [
"s3:PutObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::[mybucket]/*"
}
]
}
还有 curl POST:
curl --request PUT --upload-file "thefile.gif" -k https://[mybucket].s3.amazonaws.com/uploads/
【问题讨论】:
-
真的,真的,真的没有理由允许匿名上传。没有。但是,由于您的政策需要
x-amz-acl: bucket-owner-full-control,您是否尝试过提出与您的政策一致的请求?curl ... -H 'x-amz-acl: bucket-owner-full-control' -
谢谢。那行得通。现在我正在考虑使用预签名的 POST URL 来提高安全性,但无法正确获取 curl 查询字符串。如果您可以提供帮助,请在此处创建一个新问题。 stackoverflow.com/q/43991783/3198281
标签: amazon-web-services curl post amazon-s3