Created
January 20, 2013 09:28
-
-
Save nickleefly/4577467 to your computer and use it in GitHub Desktop.
copy an image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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