Merge pull request 'Fixed download bug' (#15) from bugfix/download-cache into main

Reviewed-on: https://git.walzen665.de/Walzen665/sharepulse/pulls/15
This commit is contained in:
Max W. 2024-03-07 22:01:10 +00:00
commit 91ed183052

View File

@ -172,12 +172,20 @@ export class DownloadComponent {
const blob = new Blob([response.data], {type: 'application/octet-stream'});
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
// Check if download blob already exists and remove it if it does
let a = document.getElementById('fileDownloadBlob') as HTMLAnchorElement | null;
if (a !== null) {
a.remove();
}
a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.download = filename;
a.id = 'fileDownloadBlob';
document.body.appendChild(a);
this.saveDownloadedFile();
// Clean up by revoking the Blob URL and removing the temporary anchor (currently disabled due to saveDownloadBtn)