Last active
August 29, 2015 14:07
-
-
Save kostasx/f5b020c3fbd31e0bb428 to your computer and use it in GitHub Desktop.
Node.js - Get File using HTTPS
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 https = require('https'); | |
var fs = require('fs'); | |
var options = { | |
hostname : 'wordpress.org', | |
port : 443, | |
path : '/latest.zip', | |
method : 'GET' | |
}; | |
var file = fs.createWriteStream("wp_latest.zip"); | |
var req = https.request(options, function(res) { | |
console.log("statusCode: ", res.statusCode); | |
console.log("headers: ", res.headers); | |
res.on('data', function(d) { | |
file.write(d); | |
}); | |
}); | |
req.end(); | |
req.on('error', function(e) { | |
console.error(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment