I have a little problem that I can't figure out how to fix. I need to send my server a request with custom headers, download it to the client, and prompt a save alert of the browser.
I use AngularJS. I downloaded all the bits of the file, and I have its name. Now I need to let the client save it to his computer. Any ideas on doing it without server modification?
Here's how I download a file:
Documents.download(id).$promise.catch(function(response) {
switch(response.status) {
case '412':
toaster.pop({
type: 'error',
title: LOCALIZATION.errors.downloadingPC.title,
body: LOCALIZATION.errors.downloadingPC.message
});
break;
default:
toaster.pop({
type: 'error',
title: LOCALIZATION.errors.general.title,
body: LOCALIZATION.errors.general.message
});
break;
}
}).then(function(response) {
// the file downloaded. I have the bits of it. now what?
})