[英]how to upload big file by block use node js
I want to upload a big file by using node js,but the node js using aync mode,How do I upload the big file by block.My code looks like this: 我想通过使用节点js上传一个大文件,但节点js使用异步模式,我如何按块上传大文件。我的代码如下所示:
var i = 0;
while(i < myObj.filesize){
fs.readSync(in_fd, buf, 0, myObj.blockSize, null);
i += myObj.blockSize;
sendfile(buf); //the sendfile send data in aync mode
}
你想要的最好的方法是使用可读流和可写流:
fs.createReadStream('path/to/file').pipe(destinationStream);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.