AWS S3 响应错误 400

AWS S3ResponseError 400

我正在尝试将我的 Django 应用程序设置为 AWS。

我的 EC2 配置是 Ubuntu 14.04、Apache2、Django 1.8 和 Python 3.4。

所以我尝试按照本教程将静态文件移动到 S3:https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/

按照教程进行操作后,我终于 运行 'python manage.py collectstatic' 在我的项目中出现错误:

boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request

我的 S3 存储桶策略如下:

{
"Version": "2008-10-17",
"Statement": [
    {
        "Sid": "PublicReadForGetBucketObjects",
        "Effect": "Allow",
        "Principal": {
            "AWS": "*"
        },
        "Action": "s3:GetObject",
        "Resource": "arn:aws:s3:::MY_BUCKET_NAME/*"
    },
    {
        "Effect": "Allow",
        "Principal": {
            "AWS": "MY_USER_ARN"
        },
        "Action": "s3:*",
        "Resource": [
            "arn:aws:s3:::MY_BUCKET_NAME",
            "arn:aws:s3:::MY_BUCKET_NAME/*"
        ]
    }
  ]
}

我的 COR 配置如下:

<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>

在我的 'settings.py' 中:

INSTALLED_APPS = ( ... , 'storages', ...)

# FOR AWS
AWS_STORAGE_BUCKET_NAME = 'MY_BUCKET_NAME'
AWS_ACCESS_KEY_ID = 'MY_ACCESS_KEY_ID'
AWS_SECRET_ACCESS_KEY = 'MY_SECRET_ACCEESS_KEY'

AWS_S3_SECURE_URLS =False
AWS_QUERYSTRING_AUTH = False
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = "http://%s/" % AWS_S3_CUSTOM_DOMAIN
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

我缺少什么才能做到这一点?

更新

~/.aws/config

[default]
aws_secret_access_key = MY_SECRET_ACCESS_KEY_FROM_MY_SECURITY_CREDENTIALS
region = ap-northeast-2
output=text
aws_access_key_id = MY_ACCESS_KEY_ID_FROM_MY_SECURITY_CREDENTIALS

~/.aws/credentials

[default]
aws_access_key_id=MY_ACCESS_KEY_ID_FROM_MY_SECURITY_CREDENTIALS
aws_secret_access_key=MY_SECRET_ACCESS_KEY_FROM_MY_SECURITY_CREDENTIALS
region = ap-northeast-2

我应该正确设置“~/.boto”文件。