Reputation: 2454
I am building an app which lets users upload pictures and share it with his/her friends only.
Each user's content is stored in s3 under his own folder name, and the downloading service as explained in point 4 is the one that has to be invoked. Unfortunately, this means I cannot assign this url as source to an image tag <img src="">
, because the authorization token should be sent on GET request. I cannot make the contents of user folder public because only user and his friends are allowed to see the images. The current service will soon become a bottleneck and I would like to avoid that.
What is the recommended architecture/design to solve this problem?
Upvotes: 1
Views: 2353
Reputation: 54
The flow for downloading the images would be like this
User invokes GET request to download image
Above URL will not be valid for long time , but your images are secured. As auth token is time based it will cater your case like if some one make the image private/public remove a friend.Deleted images , Copy paste of image url etc ..
Upvotes: 1
Reputation: 200446
Instead of having a service that loads and returns the entire image file from S3, you should have a service that simply generates an S3 presigned URL. Then the URL retrieved from that service can be used in the <img src="">
tags on your site. This will be much more performant since the web browser will ultimately download the image directly from S3, while also still being secure.
Upvotes: 2