ใช้ createReadStream ส่งส่วนที่ร้องขอไปยังไคลเอนต์ การเรียกฟังก์ชัน createReadStream() จะให้ readable stream
ตัวอย่าง
โค้ดดังนี้:
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":"video/mp4"
});
stream.pipe(res);
});