Skip to content

Instantly share code, notes, and snippets.

@RizkyRajitha
Created Dec 19, 2019
Embed
What would you like to do?
const express = require("express");
const bp = require("body-parser");
const port = 5000;
const app = express();
const fs = require("fs");
const multer = require("multer");
app.use(bp.urlencoded({ extended: false }));
app.use(bp.json());
app.use(require("morgan")("dev"));
var storage = multer.memoryStorage();
var uploadMem = multer({ storage: storage });
app.post("/fileuploadmem", uploadMem.single("image"), (req, res) => {
console.log(req.file);
fs.writeFileSync('./'+req.file.originalname , req.file.buffer)
console.log(" file mem uploaded");
res.send("file mem upload success");
});
app.listen(port, () => {
console.log("Express server listning on port " + port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment