Skip to content

Instantly share code, notes, and snippets.

@nickleefly
Created January 20, 2013 09:28
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 nickleefly/4577467 to your computer and use it in GitHub Desktop.
Save nickleefly/4577467 to your computer and use it in GitHub Desktop.
copy an image
var fs = require('fs');
var readStream = fs.createReadStream('./cat.jpg');
var writeStream = fs.createWriteStream('./cat_copy.jpg');
readStream.on('data', function(data) {
writeStream.write(data);
});
readStream.once('end', function() {
writeStream.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment