0

so my file to create is like this ./example/myfilename with no extension, and nodejs createWriteStream apparently thinks it is a folder and throws Error: EISDIR: illegal operation on a directory. any way to work around this?

Blake
  • 7,367
  • 19
  • 54
  • 80
  • Couldn't reproduce. `fs.createWriteStream('/tmp/myfilename')` is working fine on my Linux desktop. – Avraham Mar 18 '19 at 09:03

1 Answers1

1

Do you mean something similar?

var http = require('http');
var fs = require('fs');

http.createServer(function(req, res) {

  let writeStream = fs.createWriteStream('./temp/output', {"flags":"a"});

  // This pipes the POST data to the file
  req.pipe(writeStream);

  req.on('end', function () {
    res.writeHead(200, {"content-type":"text/html"});
    res.end('All went ok.');
  });

  writeStream.on('error', function (err) {
    console.log(err);
  });
}).listen(8080);

This pipes well my Postman posting to the file.

K.K.
  • 31
  • 1
  • 6