Skip to content

Instantly share code, notes, and snippets.

@flammenmensch
Created October 25, 2013 14:21
Show Gist options
  • Select an option

  • Save flammenmensch/7155432 to your computer and use it in GitHub Desktop.

Select an option

Save flammenmensch/7155432 to your computer and use it in GitHub Desktop.
var fs = require('fs'),
request = require('request');
var download = function(uri, filename){
request.head(uri, function(err, res, body){
console.log('content-type:', res.headers['content-type']);
console.log('content-length:', res.headers['content-length']);
request(uri).pipe(fs.createWriteStream(filename));
});
};
download('https://www.google.com/images/srpr/logo3w.png', 'google.png');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment