NodeJS/Express – RestAPI to Upload Multipart File to MySQL using Multer + Sequelize ORM
In the tutorial, we show how to build a NodeJS/Express RestAPI to upload Multipart Files/Images to MySQL using Multer middleware and Sequelize ORM.
Related posts:
- NodeJS – Save File/Image to MySQL by Sequelize with BLOB type
- Multer – Build RestAPI to upload a MultipartFile to NodeJS/Express
Goal
Prerequisites
- NodeJS – Save File/Image to MySQL by Sequelize with BLOB type
-
Multer – Build RestAPI to upload a MultipartFile to NodeJS/Express
Objective
In the tutorial, we create a NodeJS project that build RestAPI to upload files/images to MySQL database, see below project structure:
/NodeJS-Express-Multer-Upload-MultipartFile-Sequelize-MySQL
/app
/config
db.config.js
env.js
upload.config.js
/controllers
upload.controller.js
/models
img.model.js
/routers
upload.router.js
/node_modules
/resources
/static
/assets
/uploads /* the folder is used to store uploaded files/images in disk*/
/tmp /* the folder is used to store files/images which are retrieved from MySQL database*/
package.json
server.js
Using PostMan to make a POST request:
-> result:
Practice
Setting up NodeJS/Express project
Create a folder 'NodeJS-Express-Multer-Upload-MultipartFile-Sequelize-MySQL':
More at:
NodeJS/Express – RestAPI to Upload Multipart File to MySQL using Multer + Sequelize ORM
Top comments (0)