我似乎无法让它正常工作。我想将一些数据写入gzip流,然后将gzip流传输到文件写入流中。然后在文件写入完成时调用一个函数。我目前有以下代码:
var gz = zlib.createGzip()
.pipe(fs.createWriteStream(gz_path));
gz.write(data);
gz.on('error', function(err){
console.log("wtf error", err);
});
gz.on('finish', function(){
console.log("write stream is done");
dosomething();
});
完成事件或错误事件从未被调用。
end()
关闭gz
流。 - user568109