Closed ybitso closed 8 years ago
Anything ?
Once you have logged in, you should store the cookies and user other modules, like httpreq or request to download the xlsx.
httpntlm is build for authentication.
I can access the file, it downloads, but seems to download more data than it should for the excel; csv are fine
var url = 'https:\\......\file.xlsx';
var localpath = 'd:\'
var localfile = 'savedfilename.xlsx';
var file = fs.createWriteStream(localpath + localfile);
httpntlm.get({
url: url,
username: 'myusername',
password: 'mypassword',
workstation: 'myworkstation',
domain: '',
}, function (err, res){
if(err) {
console.error(err);
}
else {
file.write(res.body);
file.end(function () {
console.log('Done');
process.exit()
})
}
});
Yes, I know. That's because it converts all responses to an UTF8 String. res.body is a String, not binary data. That's why it works with a CSV (which is pure text and so converting it to string doesn't mess it up).
If you really want to download binary data, use the binary option as described here: https://github.com/SamDecrock/node-httpreq
httpntlm.get({
url: url,
username: 'myusername',
password: 'mypassword',
workstation: 'myworkstation',
domain: '',
binary: true
}, function (err, res){
if(err) {
console.error(err);
}
else {
file.write(res.body);
file.end(function () {
console.log('Done');
process.exit()
})
}
});
Let me know if it works
That worked, Thank you
Hi,
i use httpntlm fine with CSV files, but attempting to download xlsx, it downloads more bytes than it suppose to; appears to be encoding the data differently. Any ideas?
Thanks, A