title: Compressing File Uploaded From Multer using Nodejs Zlib
body: <p>I am trying to compress an uploaded file using nodejs zlib.The compression works but trying to uncompress it throws an error.I created a compress route which is a post request to upload the file to be compressed:</p>
  <pre><code>app.post('/compress', upload.single('file'), (req, res) =&gt; {
    try {
      var streamInstance = new stream.Readable();
      const destination = createWriteStream(`compressed/${req.file.originalname}.gz`);
      const source = streamInstance.push(Buffer.from(JSON.stringify(req.file)))
      res.json(source)
      streamInstance.push(null);
      pipeline(source, gzip, destination, (err, file) =&gt; {
        if (err) {
          console.log(err)
          return res.json('An error occurred:', err);
        } else {
          console.log({
            file: file
          })
          return res.json(file)
  
        }
      })
    } catch (err) {
      console.log(err)
      res.json(err)
    }
  })
  </code></pre>
  <p>This add the compressed file in the compressed directory but trying to uncompress it throws an error.</p>
  <p>Is there another method i could use in compressing this file using zlib?</p>