DEV Community

loading...

Orientation about store files/images in backend

Marcos Aguilera Ely
Web & Mobile Dev / #ReactJS & FrontEnd lover 🖖 / @bower not yet used!
・1 min read

Hi fellows!

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

Context:

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.

Discussion (3)

Collapse
rhymes profile image
rhymes

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.

Collapse
marcode_ely profile image
Marcos Aguilera Ely Author • 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.

Collapse
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