如何从writeStream获取文件名?

fed*_*asu 2 javascript stream node.js

这是我想做的:

stream = fs.WriteStream('crap.txt',{flags:'w'};
// more code
response.on('close',function() {
      // is the below line possible?
      fs.stat(stream.name, function(stats) {
            console.log(stats.size);
      });
      stream.end();
});
Run Code Online (Sandbox Code Playgroud)

那么我可以从流对象获取文件名吗?结合可写流上的优秀教程/文档(包含示例),一个示例性示例将是一个不错的选择。

gen*_*nry 7

fs.createWriteStreamstream.path

您可以console.dir(stream)找到所有属性