Created
February 25, 2020 13:30
-
-
Save heytulsiprasad/a3ab87b4c06abba2bc11a3689eb3c7ab to your computer and use it in GitHub Desktop.
get started with multer npm package for uploading files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js >>> root file of /src | |
const multer = require("multer") | |
const express = require("express") | |
const app = express() | |
const upload = multer({ | |
dist: "images" | |
}) | |
app.post("/user/avatar", upload.single("avatar"), (req, res) => { | |
res.send(); | |
}) | |
// "avatar" in upload.single refers to the key value provided in form-data | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment