Using Multer - How do I read an uploaded file (text/.csv)

I hope below answer will resolve your problem.

Add

app.use(multer({
  dest: 'uploads/'
}));

after

app = express(); 

In the request handler you can access file details as below

 req.files 

For example in the input field name is "test". You can access file details as below.

req.files.test
req.files.test.path

will give you exact path of the file.

So you can use

let data = fs.createReadStream(req.files.test.path,'utf8');

then you can take a look at

console.log(data);

When you configure Multer you should assign what is the destionation of the uploaded file

something like this:

var upload = multer({ dest: 'uploads/' })

then, you can just read the file from storage with node file system


An alternative is the access the multer file Buffer object directly.

Calling to string on this object will try and parse out the string in UTF-8 by default.

eg: bufferByteArray.toString();

https://nodejs.org/api/buffer.html