I am using angular $http to download file from server. file types can be different. I should set request header in order to authentication. when download finishes, file is corrupted! here is my code in client side to save the file:
getFile: function(file) {
$http({
method: 'GET',
url: 'download' + "/" + file.name,
headers: {
"X-AUTH-TOKEN": "my-token",
Accept: "*/*",
}
}).success(function(data) {
var fileBlob = new Blob([data], {
type: '*/*;charset=utf-8'
});
saveAs(fileBlob, file.name);
}).error(function(err) {
console.log('err', err);
});
}