1

I'm building an application using Angular 10. I have a function that downloads files from a local server. This function works fine for extensions - .PDF, .xlsx, etc. , except files with .msg extension. On download, it returns a file of size 0KB.

.msg files

This is my function:

downloadFile(url:string,fileName:string){
  fetch(url)
  .then(res => res.blob())
  .then(blob => {
    
    var a = document.createElement("a");
    document.body.appendChild(a);
    a.style.display = "none";

    var url = window.URL.createObjectURL(blob);

    a.href = url;
    a.download = fileName;
    a.click();
    window.URL.revokeObjectURL(url);
  });
}

I tried to use these headers but still, it didn't work:

application/octet-stream

application/download

How do I resolve this problem?

Anglesvar
  • 1,132
  • 8
  • 15
9Dan7
  • 43
  • 6

1 Answers1

0

Use application/vsd.ms-outlook as MIME type for .msg extension.