尝试使用以下代码为上传到S3存储桶中的文件生成可公开访问的URL:
client = boto3.client('s3', config=botocore.client.Config(signature_version=botocore.UNSIGNED))
client.put_object_acl(Bucket="my-bucket", Key=filename, ACL='public-read')
引发异常:
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the PutObjectAcl operation: Access Denied
我的S3存储桶具有以下策略:
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {}
}
]
}
任何提示都将受到欢迎! 谢谢