DEV Community

António Avelar
António Avelar

Posted on

2

(NodeJS + Express + Multer) Any suggestions of how can i serve user uploaded files?

Hi!, i'm building a Web App where a user can upload pictures. For the task of receiving the binary files i'm using Multer.
So... Multer stores the pictures in the filesystem by default without the file extension. I'm storing the file data (original name, mimetype, extension, path, ...) in the database.

How should i serve those files to the user?
Should i use a route, that gets the image data (extension, mimetype, ...) and then sends the file with the right mime type?
Or should i use the express.static("path/to/folder")?

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay