Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var filename = req.files.file.name;
- var tmpFilepath="./upload/"+ guid();
- fs.rename(req.files.file.path,tmpFilepath);
- fs.createReadStream(tmpFilepath)
- .on('end', function() {
- console.log("file Saved");
- })
- .on('error', function() {
- console.log("error encountered");
- // res.send('ERR');
- })
- // and pipe it to gfs
- .pipe(writestream);
- writestream.on('close', function (file) {
- fs.unlink(tmpFilepath);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement