I am trying to open a blob with file type PDF
in IE the name of the blob is working and downloading as well.
But for Chrome and Firefox i am opening it up in a new tab and the name in the new tab comes exactly the same of blob name.
I want to change the file name but didn't found any way of doing that.
Below is the code i am trying with.
this.downloadReport().subscribe(
data => {
var blob = new Blob([data], { type: 'application/pdf' });
var newWindow = window;
if (newWindow.navigator && newWindow.navigator.msSaveOrOpenBlob) {
var fileData = [data];
var blobObject = new Blob(fileData);
window.navigator.msSaveOrOpenBlob(blobObject, filename);
self.alertService.stopLoadingMessage();
} else {
var objectUrl = URL.createObjectURL(blob);
setTimeout(function () {
var newWindow = window.open(objectUrl);
setTimeout(function () {
newWindow.focus();
newWindow.print();
self.alertService.stopLoadingMessage();
}, 1000);
}, 2000);
}
},
err => {
this.alertService.showStickyMessage('Problem while downloading the file.');
console.error(err);
}
);