方法一:
var fs=require('fs');
var readStream=fs.createReadStream('1.mp4');
var writeStream=fs.createWriteStream('1-stream.mp4');
readStream.on('data',function(chunk){
if( writeStream.write(chunk) ===false ){
console.log('still cached');
readStream.pause();
}
})
readStream.on('end',function(){
writeStream.end();
})
writeStream.on('drain',function(){
console.log('data drains');
readStream.resume();
})
方法二(pipe|管道):
var fs= require('fs');
fs.createReadStream('1.mp4').pipe(fs.createWriteStream('1-pipe.mp4'));