Govi-Boy
Govi-Boy

Reputation: 99

how to get files uploaded by multer

I uploaded files to a folder in back-end using a node library.Now I want to get files from that folder by filename,from a one route.here

Upvotes: 1

Views: 203

Answers (1)

Erni Souza
Erni Souza

Reputation: 310

I am not sure what you really need. But you may use nodejs file system to do such a thing (https://nodejs.org/api/fs.html).

https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback

fs.readFile('/your/file', (err, data) => {
  if (err) throw err;
  console.log(data);
})

https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback

fs.readdir('/your/directory/path', (err, data) => {
  if (err) throw err;
  console.log(data);
})

Upvotes: 1

Related Questions