1. 设置公共访问,将阻止关闭
2. 设置访问权限
3.设置存储桶策略
{
"Version": "2012-10-17",
"Id": "Policy",
"Statement": [
{
"Sid": "Stmt",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket_name/*"
}
]
}
{
"Version": "2012-10-17",
"Id": "Policy",
"Statement": [
{
"Sid": "Stmt",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetBucketCORS",
"s3:PutBucketCORS",
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::bu",
"arn:aws:s3:::bu/*"
],
"Condition": {
"StringLike": {
"aws:Referer": [
"https://www.com/*"
]
}
}
}
]
}
4.修改跨域访问
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>