I am uploading documents via the AWS API to an S3 bucket. Works fine.
The items that are uploaded are marked as private though, so cannot be viewed online. I can get around this by right-clicking the file in the Console and clicking 'Make Public', or by using the API to make it public.
Is it possible to make all files uploaded public, so I don't have to make additional API calls to do so?
The following is a screenshot of the bucket's permissions:
I don't think it's anything to do with IAM, as the requesting user isn't a user at all, it's the public.
Thanks
This can be done with a bucket policy (click bucket policy in your screenshot). e.g.,
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::examplebucket/*"]
}
]
}
(see "Granting Read-Only Permission to an Anonymous User" on https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html)
That allows anyone (*
) to perform GetObject
on any item in the bucket, rather than having to set the permissions per-item.
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