title: how to read file from incoming request without saving it to local disk using node.js express?
body: <p>I have my back-end <code>server</code> in <code>express(node.js)</code> and all <code>apis</code> is running on this <code>server</code>. I also have <code>file-upload</code> mechanism for <code>file-upload</code> <code>api</code> using <code>multer</code>. For file uploading i have created a <code>middleware</code> and in my <code>helper</code> <code>controller</code> i have this</p>
  <pre><code>const storage = multer.diskStorage({
  
  destination: (req, file, cb) =&gt; {
      let path = getFileStoragePath(req, file);
      console.log(`path to create ${path}`)
          // let path = `uploads/transId${req.body.refrenceId}/transporter`
      checkDirectory(path, (err) =&gt; {
          if (err) {
              console.log(`Error occured if checkDirectory ${err.message}`)
              cb(err, null)
          } else {
              cb(null, path);
          }
      });
  },
  filename: (req, file, cb) =&gt; {
      let dateNow = new Date()
      cb(null, `${file.fieldname}_${dateformat(dateNow, 'dddd_mmmm_dS_yyyy_h_MM_ss_TT')}${path.extname(file.originalname)}`)
   }
  });
  
  const saveFilesToFolder = async(req, res, next) =&gt; {
  const upload = multer({
      storage: storage,
      fileFilter: imageFilter,
      limits: {
          fileSize: 1024 * 1024 * 10
      }
  }).any();
  
  upload(req, res, (err) =&gt; {
      const wasValidRequest = checkAllowedFiles(req);
  
      if (wasValidRequest.status === false) {
          return res.send({
              status: false,
              message: wasValidRequest.message,
              response: null
          })
      }
  
      // counter = 0
      if (err) {
          console.log(`Error uploading files, ${err.message}`)
          return res.send({
              status: false,
              message: `Error occurred while uploading files, ${err.message}`,
              response: null
          })
      }
  
      // WHEN FILE UPLOADING IS DONE NOW PASSING THE REQUEST
      next();
   });
  };
  </code></pre>
  <p>And in my <code>route.js</code> file i have attached my <code>middleware</code> to save <code>files</code> into folder and reading <code>files</code> like this</p>
  <pre><code>router.post('/upload-files', saveFilesToFolder, catchAsyncErrors(fileController.UploadFiles));
  </code></pre>
  <p>but now my requirement is that i want to read the <code>content</code> of <code>file</code> which is coming in <code>incoming request</code>without saving that file to local <code>disk</code> by accessing the file inside my <code>fileController</code> <code>function</code> and i want to make a separate api for this purpose?</p>
  <p>How can i do this</p>