Amazon web services AWS S3 bucket,只有手动将单个对象权限设置为公共后,才能访问上载的图像文件
我已经创建了一个bucket&在从我的网站开发服务器上传图像后,它将存储为XML文件,如果我转到bucket并手动将其公开,它将对所有人可用,并且我能够获得该文件 这里可能有什么问题 将每个上载的文件设置为公共,如下所示 I setAmazon web services AWS S3 bucket,只有手动将单个对象权限设置为公共后,才能访问上载的图像文件,amazon-web-services,amazon-s3,Amazon Web Services,Amazon S3,我已经创建了一个bucket&在从我的网站开发服务器上传图像后,它将存储为XML文件,如果我转到bucket并手动将其公开,它将对所有人可用,并且我能够获得该文件 这里可能有什么问题 将每个上载的文件设置为公共,如下所示 I setaccess=对象可以是公共的 Block all public access = False CORS配置 <?xml version="1.0" encoding="UTF-8"?> <CORSConf
access=对象可以是公共的
Block all public access = False
CORS配置
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<ExposeHeader>ETag</ExposeHeader>
<ExposeHeader>x-amz-meta-custom-header</ExposeHeader>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
设置本身就是为了让他们能够公开 如果需要所有对象(或具有特定前缀的对象),请查看创建一个S3 bucket策略,该策略允许
S3:GetObject
权限
此bucket策略的一个示例可用
若我进入bucket并手动将其公开,它将对所有人可用,并且我能够获取该文件。这里可能有什么问题
你不必手动操作。相反,要自动使bucket中的所有对象公开可读,可以添加bucket策略:
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"PublicRead",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::<your-bucket-name>/*"]
}
]
}
{
“版本”:“2012-10-17”,
“声明”:[
{
“Sid”:“PublicRead”,
“效果”:“允许”,
“委托人”:“*”,
“操作”:[“s3:GetObject”],
“资源”:[“arn:aws:s3:::/*”]
}
]
}
您还需要保持禁用阻止公共访问设置。谢谢,我应该将上述代码粘贴到哪里?这是否在bucket策略中?@AnoopKGeorge其在bucket中的
权限选项卡位于bucket策略下。
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"PublicRead",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::<your-bucket-name>/*"]
}
]
}