我从相册中选了一张图片,大小应该有好几兆这样,每次调用tcp.write都出现相同问题,
都是写到516k的时候就报错,请问怎么解决?
以下是部分代码
const BUFFER_LEN = 2048;
const fs = wx.getFileSystemManager();
var buffer = new ArrayBuffer(BUFFER_LEN);
const fd = fs.openSync({
filePath: filepath,
flag: "r"
});
do {
var readTotalBytes = 0;
var res = fs.readSync({
fd: fd,
arrayBuffer: buffer,
length: BUFFER_LEN
});
readTotalBytes = res.bytesRead;
tcp.write(res.arrayBuffer.slice(0,readTotalBytes));
if(readTotalBytes < BUFFER_LEN)
{
console.log("total send " + totalSendData.toString() +" bytes.");
break;
}
console.log(readTotalBytes);
}
while (readTotalBytes > 0)
同问题