Skip to content

Instantly share code, notes, and snippets.

@rdiego26
Created August 30, 2013 19:51
Show Gist options
  • Save rdiego26/6393643 to your computer and use it in GitHub Desktop.
Save rdiego26/6393643 to your computer and use it in GitHub Desktop.
getFile.js
/**
* User: ramos
* Date: 29/08/13
* Time: 17:41
*/
var https = require('https');
var fs = require('fs');
var fileName = 'isv15.zip';
var file = fs.createWriteStream("/tmp/" + fileName);
var req = https.request({
host: 'dominio.com.br',
port: 80,
username: 'usuario',
password: 'senha',
path: '/pasta/servlet',
method: 'GET',
rejectUnauthorized: false,
requestCert: true,
agent: false
}, function(res) {
res.on('data', function(data) {
file.write(data);
}).on('end', function() {
file.end();
console.log("File downloaded!");
});
});
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