Skip to content

Instantly share code, notes, and snippets.

@niceue
niceue / streamCopy
Created June 14, 2015 08:58
stream copy file
var fs = require('fs');
function streamCopy(src, dest, callback) {
if (typeof callback !== 'function') {
callback = function(){};
}
fs.stat(src, function (err, stats) {
if (err) return callback(err);
var readStream = fs.createReadStream(src);
var writeStream = fs.createWriteStream(dest);