DEV Community

Marcos Aguilera Ely
Marcos Aguilera Ely

Posted on

Orientation about store files/images in backend

Hi fellows!

I'm writing here looking for wisdom about good practices to prepare and develop my backend.


I want to develop a backend that allows to store files/images that comes from a User UI. Those images should be uploaded via RestFul Api and store in the backend.

Your help

You'll help if you can share some knowledge about your way to store file/images in the backend exposing a api to achieved it.

  • Which technology have you use to achieved it?
  • Will you use Node.js backend to it?
  • How would you store the files/images? Blob to a db or files with ref?
  • Which framework could help?

Thanks a lot for your help.

Top comments (3)

rhymes profile image

I implemented something like it in the following way:

  1. Setup a S3 bucket to hold pictures
  2. Endpoint to retrieve temporary tokens for the upload
  3. JS client that retrieves such token and then uploads directly to S3
  4. Endpoint to associate the resource with the URL

Basically instead of uploading to the backend you upload directly to the remote storage, retrieve the URL and use it. This way you avoid impacting your own servers for the upload.

Bonus points: you can use resizing services like Cloudinary that also act as CDNs.

marcode_ely profile image
Marcos Aguilera Ely • Edited

Ey, How could I invite you a beer? :)

Thanks a lot for your orientation, I'm gonna check S3 bucket for these purpose.

Man, it really helps. Thanks so much.

rhymes profile image
rhymes • Edited

No worries!

Heroku has a tutorial with S3 + Node.js, I'm sure other cloud storage systems have something similar: Direct to S3 File Uploads in Node.js