amazon web services - Best way to retrieve files from AWS S3 with Spring Boot? -
i'm working on spring boot app using postgresql database , s3 bucket storage images. when saving new entry i'm uploading image s3 bucket , saving name db. retrieve image s3 bucket need prepend url pattern in view this:
<img th:src="@{'https://s3.us-east-2.amazonaws.com/mybucketname/test/'+${entry.image}}" height="256" width="256"/>
but, see image need make incoming file "test" folder public adding new policy s3 bucket this:
{ "version": "2008-10-17", "statement": [ { "sid": "allowpublicread", "effect": "allow", "principal": { "aws": "*" }, "action": "s3:getobject", "resource": "arn:aws:s3:::mybucketname/test/*" } ]
}
questions:
- is save approach?
- can retrieve files in different way?
you doing fine. need make sure not give permission list contents of buckets viz. if type https://s3.us-east-2.amazonaws.com/mybucketname/test/ on browser should not list file names in folder.
as mentioned mohan; can configure cdn (in front of s3 bucket) retrieve files; improve load time customers.. configuration , cost involved , useful if have lots of geographically distributed customers.
Comments
Post a Comment