Use case: We are developing a web application and the client has requested us to use AWS S3 to store the images. In the application, Everyone will have their own account and would upload their own images, some of the uploaded images will be public.
According to my understanding we can achieve this by using pre-singed URLs, to upload the images. But the problem that I am facing is, how to restrict access to the images to the other users.
There are two basic ways to use Amazon S3:
In the first case, only your application has access to the data/files stored in S3. It must retrieve the content and serve it to users. This is a traditional approach for web servers.
In the second case, you can generate HTML pages that contain references to files stored in S3. For example, if an image appears within a web page, the src=
parameter would point to an Amazon S3 URL. The file is then served from S3 without going via your web server.
This can be enhanced by using Pre-Signed URLs, which are time-limited URLs that provide access to private content stored in Amazon S3. It works like this:
A Pre-Signed URL consists of:
The Pre-Signed URL can be created in just a couple of lines of code and does not require a call to the AWS API.
Bottom line: Keep all images private. Your application confirms each user's right to access the images on-the-fly, then generates URLs to grant time-limited access.
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