0

We are having an issue in office add-in with Mac. We can't download file from office-add-in on mac. Same add-in working fine with windows platform.

We have constructed as blob type data from our API Response. Same blob type passing into FileSaver.js of SaveAs method. We are using FileSaver.js to saving files on the word office add-ins.

Note : Everything work fine on windows platform. We already have implementation of html download link attribute same as in following link sample but that won't be use due to security concern.

https://github.com/OfficeDev/Office-Add-in-JavaScript-FileDownload

Force download a pdf link using javascript/ajax/jquery

Here are the our sample code.

var getMessageUrl = "https://test.xxx.xxx/api/xxx/testcontroller/GetTest?id=121212121212";
   
   var oReq = new XMLHttpRequest();

   
   oReq.open("GET", getMessageUrl, true);
   oReq.responseType = "arraybuffer";
   oReq.setRequestHeader('X_ConnectTo', 'X-Author-CRM');
   oReq.setRequestHeader('Access-Control-Allow-Origin', '*');
   oReq.setRequestHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS');
   oReq.setRequestHeader('Access-Control-Allow-Headers', 'Authorization, Content-Type,Accept, Origin');
   oReq.setRequestHeader('Authorization', 'Bearer XXXXXXXXX-Token-XXXXXXX');
   oReq.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
   oReq.onload = function (oEvent) {
    var blob = new Blob([oReq.response], { type: "application/octet-binary" }); 
    saveAs(blob, 'Test1234.docx');
   };

   oReq.send();

here

we are getting following issue on mac enter image description here

1 Answers1

0

I wonder if the issue is similar to what we found with Script Lab, https://github.com/OfficeDev/script-lab/issues/458? If so, it may be a platform bug/limitation, though it would be good to investigate it further. See more in that issue. If you can confirm whether it's the same issue or not, it would be a good first step. Thanks!

  • Michael, It's the same issue. We can download from safari 10.1 version but not from office add-ins on mac. I think, looks like the FileSaver library would not work for it. Mac Office uses the WebKit control to embed Script Lab, and it looks like it is not currently possible for the blob download approach FileSaver uses to work with this control using public WebKit API. What would be next steps on this issue or altenative? – Keyur Patel Jul 06 '17 at 04:54
  • Let me follow up with a developer who works on the Mac add-in hosting. I recommend you subscribe-to/follow the GitHub thread about this issue on Script Lab, do you see if we reach any conclusions there… – Michael Zlatkovsky - Microsoft Jul 06 '17 at 15:19
  • I can see last comment from @dsaunders45459 on https://bugs.webkit.org/show_bug.cgi?id=174076 on decidePolicyForNavigationAction API but not much clarity on this. Can we open case in Microsoft? This is really urgent for us. – Keyur Patel Jul 06 '17 at 18:07
  • I have forwarded the question to a dev who works on the Mac add-in integration. You can also open an issue on the newly created office.js repo: https://github.com/OfficeDev/office-js/issues – Michael Zlatkovsky - Microsoft Jul 07 '17 at 01:34
  • Thanks Michael, I have also created issue on github. https://github.com/OfficeDev/office-js/issues/3 , How can we know about timeline for this fix? – Keyur Patel Jul 07 '17 at 04:54