How to make all the files default to public in Amazon S3 bucket
After so long I am writing this another post on amazon web services. Yes, I want to share my another experience with Amazon S3 bucket. I am using S3 bucket to store my video files that I stream through my website. And all videos are added to the bucket using S3 API. But the problem is the videos are not accessible to the public unless I make each video public. Every new video added thus had to be made public from the aws console. And it was so hard to do this. And therefore I was looking for a solution for this. And viola, I found it. Amazon S3 bucket has this thing done using bucket policy. In this post, I will help you add bucket policy so that you too can have all your files in S3 bucket public accessible if you want them too.
To add the bucket policy select the bucket and click on properties tab on the top right corner, then on the right side a column will appear with options like static permissions, web hosting, logging, notifications, life cycle. To add the bucket policy click on permission to expand as shown in the figure below.
Then you can click on add bucket policy to and a pop will appear where you need to add the following code replacing your_bucket_name with your real S3 bucket name:
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your_bucket_name/*"
}
]
}
Click on save, and again click on save on the permissions tab.
And now, all your files will be publicly accessible along with all the new files added to the bucket.
Comments
Post a Comment