DEV Community

loading...

NodeJS/Express – RestAPI to Upload Multipart File to MySQL using Multer + Sequelize ORM

loizenai profile image loizenai ・2 min read

https://grokonez.com/node-js/nodejs-express-restapi-to-upload-multipart-file-to-mysql-using-multer-sequelize-orm

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:

Goal

Prerequisites


/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:

NodeJS-Express-Multer-Upload-MultipartFile-MySQL-Sequelize-upload-from-postman

-> result:

NodeJS-Express-Multer-Upload-MultipartFile-MySQL-Sequelize-saving-to-mysql table

Practice

Setting up NodeJS/Express project

Create a folder 'NodeJS-Express-Multer-Upload-MultipartFile-Sequelize-MySQL':

More at:

https://grokonez.com/node-js/nodejs-express-restapi-to-upload-multipart-file-to-mysql-using-multer-sequelize-orm

NodeJS/Express – RestAPI to Upload Multipart File to MySQL using Multer + Sequelize ORM

Discussion (0)

Forem Open with the Forem app