In Angular app when I try to open a blob file received from the api using the following method in Chrome or Edge browser, a new tab opens with raw text instead of the corresponding file.
static openFileInTab = (blob: Blob) => {
const url = URL.createObjectURL(blob);
window.open(url, '_blank');
};
or
static openFileInTab = (blob: Blob) => {
const url = URL.createObjectURL(blob);
const anchor = document.createElement('a');
anchor.href = url;
anchor.target = '_blank';
anchor.click();
};
In Firefox both of the following methods work correctly, but not in Chrome/Edge.
How do I solve this problem?