[ADF-4926] fix attachments downloading (#5134)

* fix attachments downloading

* update code and tests
This commit is contained in:
Denys Vuika
2019-10-10 12:06:37 +01:00
committed by Eugenio Romano
parent 2def8d0557
commit b1d0c50e88
7 changed files with 110 additions and 85 deletions

View File

@@ -86,4 +86,23 @@ export class DownloadService {
downloadJSON(json: any, fileName: string): void {
this.saveData(json, 'json', fileName);
}
/**
* Invokes the download of the file by its URL address.
* @param url Url address pointing to the file.
* @param fileName Name of the file download.
*/
downloadUrl(url: string, fileName: string): void {
if (url && fileName) {
const link = document.createElement('a');
link.style.display = 'none';
link.download = fileName;
link.href = url;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
}