When I access this url through browser it will ask me to download the file
https://some-domain.com/api/v1/file/log123.tar.gz?type=log
And I need to download this from angularjs http request
I written a factory for this, but its not downloading
Request getting 200 status but still showing loader 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);
}
}
}]);
This is an old post but I will respond incase of current needs.
Your http request should have an additional header. Set responseType: "arraybuffer".
Then you can transform that response into a blob obj. and pass it to the callback as such: URL.createObjectURL(new Blob([response]));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.