以下是形成的请求:
请求网址:https://remoteserverurl.docx 请求方法:GET 状态码:200 OK 远程地址:10.232.4.216:7317 推荐人政策:降级时不推荐人 接受:text / html,application / xhtml + xml,application / xml; q = 0.9,image / webp,image / apng, / ; q = 0.8 接受编码:gzip,deflate,br 接受语言:en-US,en; q = 0.9 连接:保持活动状态 Cookie:isPageflowTouch = true; schemaId = 1; updCtx = true; typeId = 91433788276151561974313054830 主机:domain.test.com 不安全升级请求:1 用户代理:Mozilla / 5.0(Windows NT 6.1; Win64; x64)AppleWebKit / 537.36(KHTML,如Gecko)Chrome / 68.0.3440.106 Safari / 537.36
答案 0 :(得分:0)
function getdocx(url){
var oReq = new XMLHttpRequest();
var arrayBuffer;
oReq.open('GET', url, true);
oReq.responseType = "arraybuffer";
oReq.onload = function (oEvent) {
arrayBuffer = oReq.response; // Note: not oReq.responseText
var binary = '';
var bytes = new Uint8Array( arrayBuffer );
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
var contentfromDocx = window.btoa( binary );
//do what ever you want with this
oReq.send(null);
}