Skip to content

Instantly share code, notes, and snippets.

@Abdullamhd
Created September 30, 2019 19:53
Show Gist options
  • Save Abdullamhd/2376176cf1762ae08f42dcfd341e7125 to your computer and use it in GitHub Desktop.
Save Abdullamhd/2376176cf1762ae08f42dcfd341e7125 to your computer and use it in GitHub Desktop.
write income files as stream in node js and express
const express = require('express')
const multer = require('multer')
const upload = multer()
const app = express()
var fs = require('fs');
app.post('/',upload.array('file',4),(req,res)=>{
req.files.forEach((file)=>{
console.log(file)
var stream = fs.createWriteStream(file.originalname)
stream.write(file.buffer)
stream.end()
})
res.end()
})
app.listen(3000,()=> console.log('running'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment