download any file type with blob function
private saveAsBlob(data: any) {
 const blob = new Blob([data._body],
 const file = new File([blob], 'image.png',
 FileSaver.saveAs(file);
}
                i got it like this it work with url:
download(row) {
    return this.Http
      .get(url, {
        responseType: ResponseContentType.Blob,
      })
      .map(res => {
        return {
          filename: row.name,
          data: res.blob()
        };
      })
      .subscribe(res => {
        let url = window.URL.createObjectURL(res.data);
        let a = document.createElement('a');
        document.body.appendChild(a);
        a.setAttribute('style', 'display: none');
        a.href = url;
        a.download = res.filename;
        a.click();
        window.URL.revokeObjectURL(url);
        a.remove();
      });
  }
                        Try the following code
saveAsBlob(data: Response){
  var blob = new Blob([data._body], { type: 'image/png' });
  var url= window.URL.createObjectURL(blob);
  window.open(url);
}
                        My solution to start a download. I used this in an NgRX Effect.
// ... getting blob form somewhere
const anchor = document.createElement('a');
anchor.download = "some_file_name.txt";
anchor.href = (window.webkitURL || window.URL).createObjectURL(blob);
anchor.click();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With