Skip to content

Instantly share code, notes, and snippets.

@ajduke
Created January 24, 2016 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajduke/00966c74ea6a055b160f to your computer and use it in GitHub Desktop.
Save ajduke/00966c74ea6a055b160f to your computer and use it in GitHub Desktop.
res= <destination file stream>; // It can be standard io, another file stream, etc
readStream = fs.createReadStream(filename);
readStream.on('open', function(){
readStream.pipe(res);
});
readStream.on('error', function(err){
res.end(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment