How to Make Files Uploaded to S3 Default to Public
By default, files uploaded to Amazon S3 are private, requiring a separate action to make public. To make uploads default to public, add this policy to your S3 bucket.
{
"Version": "2008-10-17",
"Statement": [{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [ "s3:GetObject" ],
"Resource": [ "arn:aws:s3:::MY_BUCKET_NAME/*" ]
}]
}
If you aren’t sure how to add a policy, follow these steps:
- click on bucket
- expand the Permissions row
- click “Add Bucket Policy”
- copy/paste the snippet below into the text area.
- change
MY_BUCKET_NAMEto the bucket you want - submit your changes
That’s it!
If you enjoyed this tutorial, please consider sponsoring my work on GitHub 🤗