使用createReadStream将请求的部分发送到客户端。函数调用createReadStream()
将为您提供可读的流。
以下是代码-
stream = fs.createReadStream(path); stream.on('open', function () { res.writeHead(206,{ "Content-Range":"bytes " + begin + "-" + end + "/" +total, "Accept-Ranges":"bytes", "Content-Length":chunksize, "Content-Type":"new/mp4" }); stream.pipe(res); });