mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4926] fix attachments downloading (#5134)
* fix attachments downloading * update code and tests
This commit is contained in:
committed by
Eugenio Romano
parent
2def8d0557
commit
b1d0c50e88
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user