title: How to read file from createReadStream in Node.js?
body: <p>I have web appication that can upload excel file. If user upload, the app should parse it and will return some rows that file have. So, <strong>The application don't need to save file to its filesystem. Parsing file and return rows is a job.</strong> But below code, I wrote this morning, it save file to its server and then parse it.. I think it's waste server resource.</p>
  <p>I don't know how to read excel file with <code>createReadStream</code>. Without saving file, how can I parse excel directly? I am not familiar with <code>fs</code>, of course, I can delete file after the job finished, but is there any elegant way?</p>
  <pre><code>import { createWriteStream } from 'fs'
  import path from 'path'
  import xlsx from 'node-xlsx'
  
  // some graphql code here... 
  
  
  async singleUpload(_, { file }, context) {
      try {
      console.log(file)
      const { createReadStream, filename, mimetype, encoding } = await file
  
      await new Promise((res) =&gt;
          createReadStream()
          .pipe(createWriteStream(path.join(__dirname, '../uploads', filename)))
          .on('close', res)
      )
  
      const workSheetsFromFile = xlsx.parse(path.join(__dirname, '../uploads', filename))
      for (const row of workSheetsFromFile[0].data) {
          console.log(row)
      }
  
      return { filename }
      } catch (e) {
      throw new Error(e)
      }
  },
  </code></pre>