I am uploading text file to Amazon s3 bucket via java application. I want to set read access fot that file for everyone. Does anyone know how to do this ? or direct me to some appropriate resources ?
For these existing buckets, an object owner had to explicitly grant permissions to an object (by attaching an access control list). Otherwise, the bucket owner would be unable to access the object.
You can create a bucket policy that make all resources (or those who match a wildcard) available.
Click on your bucket properties on aws S3 console and edit the bucket policy to something like :
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "auniqueid",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket/*"
}
]
}
Where bucket
in the Resource
parameter is your bucket name.
Also you can set public permission for a specific file via Java API :
PutObjectRequest por = new PutObjectRequest(bucketName, key, file);
por.setCannedAcl(CannedAccessControlList.PublicRead);
s3.putObject(por);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With