Upon entering the following URL in my browser, I am prompted to download a file:
My goal is to download this file using an AngularJS HTTP request.
I have created a factory for this purpose, but unfortunately, the download is not successful.
Even though the request receives a 200 status code, the loader continues spinning in Firebug.
app.factory('File', ['$http','GENERAL_CONFIG', function($http, GENERAL_CONFIG) {
var API_URL = GENERAL_CONFIG.BASE_API_URL;
API_URL = API_URL + 'filetransfer/';
return {
download: function(filename, type,successcallback, errorcallback){
var apiurl = API_URL + filename + '?type='+type
$http.get(apiurl,{
headers: {
"Content-Type": "application/x-download;"
}
}).success(successcallback).error(errorcallback);
}
}
}]);