将文件的所有内容读入Buffer只对小文件有用。下面的代码读取条目文件(所有内容)作为缓冲区。
WebDavFS.getFile('/huge-file.zip',function(buffer){
res.end(buffer); // use a lot memory and it is not optimized
});
我需要管道webdav文件来响应(expressjs)大文件和许多客户端。
WebDAV.getStream('/huge-file.zip',function(webdav_stream)
// this code is abstract
webdav_stream.pipe(res); // use minimal memory
});