FileSystemManager.readSync和read真机调试读取失败
[图片] 关键代码: fuckWxMiniprogram(e) {
const self = this;
wx.chooseMedia({
mediaType: ["video", "image"],
sourceType: ["album"],
sizeType: ["original"],
success: async function(res) {
console.log("try to load file");
self.doReadFileByWechat(res.tempFiles)
},
fail: res => {
wx.hideLoading();
}
})
},
doReadFileByWechat(files) {
let n = 0;
const bufferSize = 1048576;
const fs = wx.getFileSystemManager();
const fd = fs.openSync({
filePath: files[0].tempFilePath,
flag: "r"
});
const stats = fs.fstatSync({ fd: fd });
while ( n < stats.size ) {
let ab = new ArrayBuffer(bufferSize);
const data = fs.readSync({
fd: fd,
arrayBuffer: ab,
length: bufferSize,
complete: res => {
console.log(res)
}
});
n += data.bytesRead;
}
}
开发者工具Window端这个API没问题,但是读取一个2G的视频文件直接内存泄漏 无力吐槽