Node ReadStream和WriteStream finish/close/end顺序
const reader = fs.createReadStream(file.path); // 创建可读流
const upStream = fs.createWriteStream(resultPath); // 创建可写流
reader.pipe(upStream);
upStream.on('finish',()=>{
console.info(' upStream finish!!')
});
upStream.on('close',()=>{
console.info(' upStream close!!')
});
reader.on('close',()=>{
console.info(' reader close!!')
});
reader.on('end',()=>{
console.info(' reader end!!')
});
输出:// reader end!!
// upStream finish!!
// reader close!!
// upStream close!!