- readFileSync 不能读取大文件吗?如何
readFileSync 不能读取大文件吗? 我需要读取最大1G的视频文件然后进行分割上传,请问有好的解决方案吗?
2021-01-08 - writeFile 问题请教?
请看我的代码 为什么for历遍完了,writeFile 才执行成功呢?这异步的吗?我需要的是每一个历遍都执行完成再执行下一个,谢谢。 for (var i = 0; i <= listSize; i++) { console.log("i:" + i) let start = i * 526095 let end = 526095 if (i == listSize) {//最后一个 end = res.size - (i * 526095) } var filestr = f.readFileSync(filePath, 'utf-8', start, end) let path = wx.env.USER_DATA_PATH + "/" + i + ".mp4" f.writeFile({ filePath: path, encoding: 'binary', data: filestr, success() { console.log("writeFile:" + path) console.log("writeFile:" + i) console.log("writeFile:" + listSize) fileList.push(path) if (i == listSize) { console.log(fileList) console.log(fileList.length) wx.hideLoading() if (fileList.length != 0) that.FileUpload(0) } }, fail(res) { console.log("writeFile:" + res.errMsg) } }) }
2021-01-07