DEV Community

loading...

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

loizenai
Software Engineer - Founder at https://loizenai.com
・2 min read

https://grokonez.com/node-js/sequelize/node-js-express-rest-api-postgresql-example-upload-file-download-file-multer-sequelize-crud

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:

Technologies

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

Goal

We create Node.js project as below:

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

Expose 3 RestAPIs:

  • router.post('/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

Practice

Setting up NodeJs/Express project

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


mkdir Node.js-Express-Upload-Download-Files-PostgreSQL
cd Node.js-Express-Upload-Download-Files-PostgreSQL

More:

https://grokonez.com/node-js/sequelize/node-js-express-rest-api-postgresql-example-upload-file-download-file-multer-sequelize-crud

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

Discussion (0)

Forem Open with the Forem app