- Newest
- Most votes
- Most comments
If you would like to preview the image from S3, you can do so by clicking the "Open" button.
I have tested this with an image, the Content-Type is system-defined to image/png and the user role had a policy with two actions s3:GetObject, s3:ListBucket. Note that opening an image directly from the "Object URL" is not the same as clicking the "Open" button.
Hello.
Are you trying to display the image in the browser using the object URL?
In that case, if you are accessing S3 directly, you will need to disable all public access blocks and set the appropriate bucket policy.
Public access block settings have account level settings and bucket level settings, so please disable both.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/configuring-block-public-access-account.html
https://docs.aws.amazon.com/AmazonS3/latest/userguide/configuring-block-public-access-bucket.html
Try using the following bucket policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::Bucket-Name/*"
]
}
]
}
In addition to the above, you can also use CloudFront to distribute images in S3, so please check the settings in the document below.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
Relevant content
- AWS OFFICIALUpdated 2 years ago
