DEV Community

Bhumanyu Kumar
Bhumanyu Kumar

Posted on

Right way of storing and fetching files with s3 privately?

Hello,

I am developing a rest api using nodejs,express and mongodb which is consumed by frontend (a spa using angular), and an android app. So, in the app(web or android) user has to upload multiple images/files and it needs to be stored on s3(privately).
My current flow of image/file upload is:

  • Image is uploaded through multipart form data from frontend.
  • Backend server receives the file buffer and uploads it to s3 bucket using aws-sdk.
  • the key return by aws-sdk to the file is stored in the db with concerned object.

Now, the problem is, i don't want to make the bucket publicly accessible. The images needs to be be shown on web as well as app to the owner of the file or admin.

If i choose to create pre-signed url for every object after fetching the records from db, i am not sure is it the right way of doing it? what if there are 100s or 1000s of images are uploaded, then i have to iterate over and make pre-signed url for each file?

Discussion (0)