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