Amazon S3-无法加载资源:服务器使用Django响应,状态为403(禁止)

时间:2018-09-14 08:08:26

标签: django amazon-s3

我正在尝试将Amazon S3用作django网站在digitalocean ubuntu 16.04中的图像存储。

第一个错误是:

加载资源失败:服务器的响应状态为403(禁止)

刷新页面后,错误变为:

跨域读取阻止(CORB)阻止了MIME类型为application / xml的跨域响应https://mybucket.s3.amazonaws.com/static/images/logo-blue.png。有关更多详细信息,请参见https://www.chromestatus.com/feature/5629709824032768

这是我的政策

{

    "Version": "2012-10-17",

    "Statement": [

        {

            "Sid": "AddCannedAcl",

            "Effect": "Allow",

            "Principal": {

                "AWS": [

                    "arn:aws:iam::681031835429:user/username"

                ]

            },

            "Action": [

                "s3:PutObject",

                "s3:PutObjectAcl"

            ],

            "Resource": [

                "arn:aws:s3:::bucketname/*"

            ],

            "Condition": {

                "StringEquals": {

                    "s3:x-amz-acl": [

                        "public-read"

                    ]

                }

            }

        }

    ]

}

这是我的CORS配置:

<CORSConfiguration>

<CORSRule>

   <AllowedOrigin>http://mywebsite。com</AllowedOrigin>



   <AllowedMethod>PUT</AllowedMethod>

   <AllowedMethod>POST</AllowedMethod>

   <AllowedMethod>DELETE</AllowedMethod>



   <AllowedHeader>*</AllowedHeader>

</CORSRule>

<CORSRule>

   <AllowedOrigin>http://www.mywebsite。com</AllowedOrigin>



   <AllowedMethod>PUT</AllowedMethod>

   <AllowedMethod>POST</AllowedMethod>

   <AllowedMethod>DELETE</AllowedMethod>



   <AllowedHeader>*</AllowedHeader>

</CORSRule>

<CORSRule>

   <AllowedOrigin>*</AllowedOrigin>

   <AllowedMethod>GET</AllowedMethod>

</CORSRule>

</CORSConfiguration>

任何朋友都能帮忙吗? 谢谢!

0 个答案:

没有答案