mui+h5 做的app,怎么下载并打开blob文件
可以下载blob文件,但是在手机上打不开blob的文件
用下面的方式在浏览器端可以打开,但是在手机端打开失败
const oReq = new XMLHttpRequest();
oReq.open('GET', fileurl.replace("#",'%23'), true);
oReq.responseType = 'arraybuffer';
oReq.withCredentials = true;
oReq.onload = function () {
const arrayBuffer = oReq.response; // Note: not oReq.responseText
if (arrayBuffer) {
const byteArray = new Uint8Array(arrayBuffer);
const aLink = document.createElement('a');
const blob = new Blob([byteArray], { type: 'application/pdf' });
let fileName = "审批单.pdf";
aLink.download = fileName;
aLink.href = URL.createObjectURL(blob);
aLink.target = '_blank';
aLink.className="J_notOpenInContainer";
document.body.appendChild(aLink);
console.log(URL.createObjectURL(blob))
aLink.click();
}
};
const form = new FormData();
form.append('_scm_token_', window._scm_token_);
oReq.send(form);
菠萝momo (作者)
我这边已经解决了 谢谢啦~
2020-12-24 10:23
DCloud_Android_DQQ
回复 菠萝momo: OK
2020-12-24 10:49
lihailan
回复 菠萝momo: 你怎么解决的,二进制流视频 下载不了
2021-01-22 15:39
1***@qq.com
回复 lihailan: 同问
2023-03-20 15:26