Is there a native ActiveX Object or similar that I can use to download a source file straight to my HDD. Currently I'm using the following:
function downloadToFile(url, file) {
var xhr = new ActiveXObject("msxml2.xmlhttp"),
ado = new ActiveXObject("ADODB.Stream");
xhr.open("GET", url, false);
xhr.send();
if (xhr.status === 200) {
ado.type = 1;
ado.open();
ado.write(xhr.responseBody);
ado.saveToFile(file);
ado.close();
}
}
But this feels a bit inefficient for a few reasons:
I'm currently using two objects in place of what could possibly be a single object.
The entire response is stored in memory until its wrote to file. This isn't an issue for the most part until I use it to download fairly large files.
Notes/Edits:
I'm working from within microsoft's MSScriptControl.ScriptControl so many web-based libraries will not help.
I'm not necessarily looking for a single object if an answer is able to write the data to file as it is received.