Node.js/Express – PostgreSQL example – Upload File/Download File – Multer + Sequelize CRUD

In the tutorial, we show how to build a Node.js/Express RestAPIs to Upload Files/Download Files to PostgreSQL using Multer middleware and Sequelize ORM.

Related posts:
Multer – Build RestAPI to upload a MultipartFile to NodeJS/Express
NodeJs/Express RestAPIs – POST/GET/PUT/DELETE requests


  • Node.js
  • Express
  • Multer
  • Sequelize
  • PostgreSQL


We create Node.js project as below:

nodejs-express-restapis-multer-upload-files-download-files-sequelize-postgresql + nodejs-project

Expose 3 RestAPIs:

  •'/api/file/upload', upload.single("file"), fileWorker.uploadFile);
  • router.get('/api/file/info', fileWorker.listAllFiles);
  • router.get('/api/file/:id', fileWorker.downloadFile);

Upload file:

nodejs-express-restapis-multer-upload-files-download-files-sequelize-postgresql + post-request-upload-file

-> PostgreSQL’s records:

nodejs-express-restapis-multer-upload-files-download-files-sequelize-postgresql + postgrsql-records

Download file:

nodejs-express-restapis-multer-upload-files-download-files-sequelize-postgresql + get-file


Setting up NodeJs/Express project

Create a folder Node.js-Express-Upload-Download-Files-PostgreSQL:

Then init Node.js project:

Install Express, Multer, Sequelize, PostgreSQL:

– Multer is a node.js middleware for handling multipart/form-data , which is primarily used for uploading files.
– Sequelize is a promise-based ORM for Node.js v4 and up. It supports the dialects PostgreSQL, MySQL …

-> package.json file:

Sequelize Model

– Create a File model, see file ./app/models/file.model.js:

Multer Config

– Create ./app/config/multer.config.js file:

Setting up PostgreSQL connection

– Create ./app/config/env.js file:

– Setup PostgreSQL connection with Sequelize in ./app/config/db.config.js file:

Express Routers

– Create ./app/routers/file.router.js file:

Download/Upload Controllers

– Create ./app/controllers/file.controller.js file:


– Create ./server.js file:

Run & Check results

Start Node.js server -> Logs:

-> Upload Files, Logs:

nodejs-express-restapis-multer-upload-files-download-files-sequelize-postgresql + post-request-upload-file

-> Get File’s info, Logs:

nodejs-express-restapis-multer-upload-files-download-files-sequelize-postgresql + get-request-file-info

-> Download Files, Logs:

nodejs-express-restapis-multer-upload-files-download-files-sequelize-postgresql + get-file



By grokonez | July 12, 2018.

Last updated on February 6, 2020.

Related Posts

2 thoughts on “Node.js/Express – PostgreSQL example – Upload File/Download File – Multer + Sequelize CRUD”

    1. @ karim make sure before posting that your are not selected aby other form for sending data in header content type www url encoded like that

Got Something To Say:

Your email address will not be published. Required fields are marked *