简体   繁体   English

Office加载项JavaScript FileDownload不适用于MAC

[英]Office Add-in JavaScript FileDownload not working with MAC

We are having an issue in office add-in with Mac. Mac的Office加载项中存在问题。 We can't download file from office-add-in on mac. 我们无法从Mac上的Office加载项下载文件。 Same add-in working fine with windows platform. 相同的外接程序可以在Windows平台上正常工作。

We have constructed as blob type data from our API Response. 我们已经根据API响应将其构造为Blob类型数据。 Same blob type passing into FileSaver.js of SaveAs method. 相同的Blob类型传递到SaveAs方法的FileSaver.js中。 We are using FileSaver.js to saving files on the word office add-ins. 我们正在使用FileSaver.js将文件保存在Word Office加载项上。

Note : Everything work fine on windows platform. 注意:在Windows平台上一切正常。 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. 我们已经实现了与以下链接示例相同的html下载链接属性,但是由于安全方面的考虑,将不使用该属性。

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

Force download a pdf link using javascript/ajax/jquery 使用javascript / ajax / jquery强制下载pdf链接

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 我们在Mac上遇到以下问题 在此处输入图片说明

I wonder if the issue is similar to what we found with Script Lab, https://github.com/OfficeDev/script-lab/issues/458 ? 我想知道问题是否与我们在脚本实验室( 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! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM