I have this code that correctly works on most of browsers except IE:
<a href="http://xxx.xxx.xxx.xxx/presets/current" download="configuration.bin">
Save
</a>
the problem is that download parameter doesn't work on IE.
To correct it I've tried this code
var request = new XMLHttpRequest();
request.open('GET', "http://xxx.xxx.xxx.xxx/presets/current", true);
request.responseType = 'blob';
request.onload = function() {
var reader = new FileReader();
reader.readAsDataURL(request.response);
reader.onload = function(e){
var blob = new Blob( [e.target.result] );
navigator.msSaveBlob( blob, 'configuration.bin' );
};
};
request.send();
On AngularJS I've also tried using $http like this code:
$http({method: 'GET', url: "http://xxx.xxx.xxx.xxx/presets/current"})
.success(function(data, status, headers, config) {
var blob = new Blob([data]);
navigator.msSaveBlob( blob, 'configuration.bin' );
})
The problem is that the file size downloaded on Chrome is 134K and the file downloaded on IE with this code is 180K
Question: How could I save file exactly as I get it?