title: Creating zip using express and archiver
body: <p>I used the node-archiver to zip files as follows. But I get corrupted zip file.</p>
  
  <pre><code>app.get('/download', async (req, res) =&gt; {
  
      const arch = archiver('zip');
      arch.append('abc', { name: 'abc.txt'});
      arch.append('cdf', { name: 'cdf.txt'});
  
      res.attachment('test.zip').type('zip');
      arch.pipe(res);
      arch.finalize();
  });
  </code></pre>
  
  <p>I modified the code to save to the file system directly. With this code, I get a working zip file created on filesystem.</p>
  
  <pre><code>app.get('/download', async (req, res) =&gt; {
  
  
      const arch = archiver('zip');
      arch.append('abc', { name: 'abc.txt'});
      arch.append('cdf', { name: 'cdf.txt'});
  
      const output = fs.createWriteStream('./test.zip');
      arch.pipe(output);
      arch.finalize();
  });
  </code></pre>
  
  <p>Why is zip file getting corrupted while sent via express <code>res</code> object? What would be the fix? </p>
  
  <p><strong>Edit:</strong>
  If I use output format as <code>tar</code> instead of zip the it works without any problem.</p>
  
  <pre><code>const arch = archiver('tar');
  </code></pre>