1

I have an addin which calls a REST API and downloads a file as a BLOB.

I am using FileSaver library to save the file in the local PC.

While everything works as expected in outlook 365 in chrome, Edge and IE11 browsers. The Outlook Desktop Client does not give the option to save the file. In fact, while debugging, I tried to look for some errors but I found none. All the code is working properly on the Outlook Desktop Client.

I want to know if the taskpane uses the IE browser, It should support the filesave.saveAs method.

I also tried to using the link

      //   const link = window.document.createElement('a');
      //   this.error = `linke = ${link}`
      //   link.href = window.URL.createObjectURL(blob);
      //   this.error = `href = ${link.href}`;
      //   this.error = link.href;
      //   link.download = this.finalName;
      //   link.click();

It also did not work on the Outlook Desktop Client and it works as expected in browser versions.

The code which I am using right now is as below:

    /**
    Angular HttpClient is used to call a rest api which returns a blob.
    which is passed to saveAs function to save the file.
    **/

    this.dsService.processAttachmentDownload(attachmentId, storageId)
    .subscribe(data => {

      const blob = new Blob([data], { type: 'application/octet-stream' });
      saveAs(blob, this.finalName);


    });
Dharman
  • 30,962
  • 25
  • 85
  • 135
Irshad
  • 1,016
  • 11
  • 30

1 Answers1

0

I believe the problem is that you are downloading the file as a blob. This isn't supported with Add-ins on Windows 32-bit or Mac. However, this post has link to a project that uses FileSaver and should be able to help. Also, are you able to tag this issue with office-js? That will help other folks who are in the know find this issue and provide assistance.

  • I am using the filesaver ` saveAs(blob, this.finalName);` `filesaver.saveAs` takes the blob as an argument. I am not sure, how do I use `filesaver ` if i dont return a blob. – Irshad Nov 18 '19 at 18:00