[Django]-[Django][AWS S3] botocore.exceptions.clienterror an error occurred (accessdenied) when calling the PutObject operation

16πŸ‘

βœ…

It was AWS S3 access problem.

In S3 bucket console, I edited bucket’s public access as public.

NB : Only do this if your intention is to make the file publicly available for example of you’re using it to serve files for your website, like images, css etc things that everyone needs to have access to.

πŸ‘€yoon

23πŸ‘

Setting AWS_DEFAULT_ACL = None worked for me. It looks like boto requests public-read ACL by default so unless you have made your bucket public it won’t work.

πŸ‘€MadeOfAir

10πŸ‘

If anyone is still having these issues, The problem is on the AWS SΒ£ bucket and You can fix the problem by enabling ACL on the s3 bucket. To do that,

  1. Go to your S3 Bucket>Permissions Tab
  2. Scroll down to Object Ownership and click on Edit
  3. Change the settings from ACL disabled to ACL enabled and save changes
πŸ‘€Gedeon

6πŸ‘

This worked for me:

In my S3 bucket -> Permissions Tab -> click Block public access -> Edit -> untick Block all public access -> Save

AND

In my AWS IAM settings -> Users Tab (under Access Management) -> <my-user> -> Add Permissions -> add AmazonS3FullAccess

This granted the user (identified by AWS id and AWS secret) access to control my s3 buckets

πŸ‘€John Johnson

1πŸ‘

By default when you create a new bucket all the public access of s3 objects are blocked(it is ticked by default). that is,you can not access the objects(read, write) through any public api’s or apps(like django apps). so, if you want to access s3 objects in the particular bucket you should set the permission to be publicly accessible(see the permission section of bucket). For further control you can add ACL(Access control list) users from the ACL section.

you can refer to this link

1πŸ‘

It is Access Control List(ACL)
Buckets -> Permission -> ACL -> Edit -> tick Everyone(public access) List and Read for Objects and bucket ACL

enter image description here

πŸ‘€joe

1πŸ‘

If you are still experiencing these difficulties, the issue lies with the AWS S3 bucket. You can resolve the problem by enabling Access Control List (ACL) on the S3 bucket. Follow the steps below to make the necessary changes:

  1. Navigate to your S3 Bucket and click on the "Permissions" tab.
  2. Scroll down to the section labeled "Object Ownership" and select the "Edit" option.
  3. Modify the settings from "ACL disabled" to "ACL enabled" and save the changes.
πŸ‘€Hamza Arif

0πŸ‘

For me the issue was wrong environment variables.

# settings file
AWS_S3_ACCESS_KEY_ID = os.environ["AWS_S3_ACCESS_KEY_ID"]
AWS_S3_SECRET_ACCESS_KEY = os.environ["AWS_S3_SECRET_ACCESS_KEY"]
AWS_S3_ACCESS_KEY_ID="random-key-id"
AWS_S3_SECRET_ACCESS_KEY="random-access-key"

After I removed the double quotes I ran the command again. It works now.

πŸ‘€harryghgim

-2πŸ‘

Setting AWS_S3_REGION_NAME=’your-region’ eg: β€˜us-east-2’

πŸ‘€Maruthesh

Leave a comment