Skip to content

Instantly share code, notes, and snippets.

@electblake
Last active January 31, 2018 19:08
Show Gist options
  • Save electblake/de66ad485a84668a8e57 to your computer and use it in GitHub Desktop.
Save electblake/de66ad485a84668a8e57 to your computer and use it in GitHub Desktop.
Node: Download something remote using request stream
var fs = require('fs'),
request = require('request');
module.exports = function (url, path, callback) {
request({uri: url})
.pipe(fs.createWriteStream(path))
.on('error', function(err) {
callback(err);
})
.on('close', function() {
callback();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment