I would like to get filename from my endpoint it's present on content-disposition but I don't know if there's a simple way to get that using JS/Angular. My endpoint returns a blob as file, and have this information in the header content-disposition
I'm using the method below to download file, since opening a new window usually is blocked by the browser
function saveFile(blob, filename) {
if (window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, filename);
} else {
const a = document.createElement('a');
document.body.appendChild(a);
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = filename;
a.click();
setTimeout(() => {
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
}, 0)
}
}