Reputation: 1891
I am trying to create zip file using express as follows.
const archiver = require('archiver');
app.get('/path/download', async (req, res) => {
const arch = archiver('zip');
arch.append('abc', { name: 'abc.txt'});
arch.append('cdf', { name: 'cdf.txt'});
arch.append('efg', { name: 'efg.txt'});
res.set('Content-Type', 'application/zip');
res.set('Content-Disposition', 'attachment; filename=test.zip');
arch.pipe(res);
arch.finalize();
});
The file gets downloaded. But when I try to open it I get Error 21
as shown in the following screenshot.
Upvotes: 1
Views: 92