Skip to content

Instantly share code, notes, and snippets.

@lyuehh
Created January 24, 2014 08:29
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 lyuehh/8593931 to your computer and use it in GitHub Desktop.
Save lyuehh/8593931 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var http = require('http');
http.get('http://img31.mtime.cn/CMS/Gallery/2014/01/01/162652.23483887_160X160.jpg', function(res) {
console.log("Got response: " + res.statusCode);
var fw = fs.createWriteStream('./img2.jpg', {flags: 'w', encoding: 'binary', mode: '0666'});
res.pipe(fw);
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment