我有一个S3桶,这里有一些图像文件。世界上任何有下载链接的人都可以下载这些文件。
但是,我想使用基本用户名和密码身份验证来限制它。不用云锋路。在aws中有没有其他可供选择的方法?在下载前启用basic auth。
发布于 2022-03-24 10:37:23
我在自定义标题中使用S3桶策略,如下所示:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "getwithauthen",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket/*.txt",
"Condition": {
"StringEquals": {
"aws:UserAgent": "username",
"aws:Referer": "password"
}
}
},
{
"Sid": "allowgetwithoutauthen",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket/*.pem"
}
]
}
然后使用curl命令获取txt文件的内容:
curl --user-agent username --referer password --request GET "https://s3-url"
但我还没有用图像测试过。我想你可以用卷曲-O来获取图像
https://stackoverflow.com/questions/71600627
复制相似问题