简体   繁体   中英

Boto3, how to disable ACL when using generate_presigned_url?

I keep getting this error:

An error occurred (AccessControlListNotSupported) when calling the PutObject operation: The bucket does not allow ACLs

I'm switching to chunked uploads, previously i could do below and this uploaded fine.

original = models.FileField(storage=S3Boto3Storage(bucket_name='video-sftp',default_acl=None),upload_to='', blank=False, null=False)

Now i'm using generate_presigned_url and the ACL parameter is being ignored.

 url = client.generate_presigned_url(
            ClientMethod="put_object",
            Params={
                "Bucket": "video-sftp",
                "Key": f"{json.loads(request.body)['fileName']}",
                "ACL": "None"
            },
            ExpiresIn=300,
        )

How do i solve?

I have omitted the parameter ACL entirely and it works:

s3_client.generate_presigned_url(
    'put_object',
    Params = {'Bucket': bucket_name, 'Key': key}
)

If you want to use the ACL parameter, maybe you shouldn't set it to the string "None" and use the value None instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM