调用PutObject操作时发生错误(AccessDenied):访问被拒绝?

时间:2019-03-07 20:41:13

标签: django amazon-web-services amazon-s3 file-upload amazon-iam

我正在按照本教程操作,以使django应用程序将文件直接上传到S3。

https://simpleisbetterthancomplex.com/tutorial/2017/08/01/how-to-setup-amazon-s3-in-a-django-project.html

创建新的IAM用户时,我启用了对S3的完全访问权限。 AmazonS3FullAccess

但是当我上传文件时,仍然出现

错误
An error occurred (AccessDenied) when calling the PutObject operation: Access Denied

然后,我尝试将策略添加到我的S3存储桶。

但是我经常收到“政策无效”的错误

{
"Version": "2012-10-17",
"Statement": [
    {
        "Effect": "Allow",
        "Action": [
            "s3:ListAllMyBuckets",
            "s3:GetBucketLocation"
        ],
        "Resource": "*",
        "Principal": { "AWS": "[my-IAM user]" }
    },
    {
        "Effect": "Allow",
        "Action": "s3:ListBucket",
        "Resource": "arn:aws:s3:::[s3-bucket-name]",
        "Condition": {
            "StringLike": {
                "s3:prefix": [
                    "",
                    "home/",
                    "home/${aws:username}/*"
                ]
            }
        },
        "Principal": { "AWS": "[my-IAM user]" }
    },
    {
        "Effect": "Allow",
        "Action": "s3:*",
        "Resource": [
            "arn:aws:s3:::[bucket-name]/home/${aws:username}",
            "arn:aws:s3:::[bucket-name]/home/${aws:username}/*"
        ],
        "Principal": { "AWS": "[my-IAM user]" }
    }
]

}

那我该怎么办?

0 个答案:

没有答案