How to Make Files Uploaded to S3 Default to Public

• 1 min read

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:

  1. click on bucket
  2. expand the Permissions row
  3. click “Add Bucket Policy”
  4. copy/paste the snippet below into the text area.
  5. change MY_BUCKET_NAME to the bucket you want
  6. submit your changes

That’s it!

If you enjoyed this tutorial, please consider sponsoring my work on GitHub 🤗

Now look what you've done 🌋
Stop clicking and run for your life! 😱
Uh oh, I don't think the system can't handle it! 🔥
Stop it, you're too kind 😄
Thanks for the love! ❤️
Thanks, glad you enjoyed it! Care to share?
Hacker News Reddit

×

Recommended Posts ✍🏻

See All »
• 3 min read
✨ HTML Share Buttons
Read Post »
• 8 min read
🚜 A Simple Web Scraper in Go
Read Post »
• 4 min read
💻 Wait for User to Stop Typing, in JavaScript
Read Post »