Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. var filename = req.files.file.name;
  2. var tmpFilepath="./upload/"+ guid();
  3. fs.rename(req.files.file.path,tmpFilepath);
  4. fs.createReadStream(tmpFilepath)
  5. .on('end', function() {
  6. console.log("file Saved");
  7. })
  8. .on('error', function() {
  9. console.log("error encountered");
  10. // res.send('ERR');
  11. })
  12. // and pipe it to gfs
  13. .pipe(writestream);
  14. writestream.on('close', function (file) {
  15. fs.unlink(tmpFilepath);
  16.  
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement