Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get name of file from writeStream?

Here is what I want to do:

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();
});

So can I get the filename from the stream object? An illustrated example would be nice, with reference to good tutorial/docs (containing examples) on writable streams.

like image 256
fedvasu Avatar asked Jan 14 '23 16:01

fedvasu


1 Answers

It's fs.createWriteStream and stream.path

You can console.dir(stream) to find all it's properties

like image 95
generalhenry Avatar answered Jan 17 '23 16:01

generalhenry