I'm testing stream to upload and download files, below is my realy simple file download route that unzip my compressed file and send it via stream :
app.get('/file', (req, res) => {
fs.createReadStream('./upload/compress_aurelien-boquet.pdf')
.pipe(unzip)
.pipe(res);
});
I'm using express 4.15.2 btw.
When i try this route it works fine the first time and shows me the pdf on my browser, but if I refresh the page then my server get this error :
events.js:163
throw er; // Unhandled 'error' event
^
Error: write after end
at writeAfterEnd (_stream_writable.js:191:12)
at Unzip.Writable.write (_stream_writable.js:238:5)
at ReadStream.ondata (_stream_readable.js:557:20)
at emitOne (events.js:96:13)
at ReadStream.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:178:18)
at ReadStream.Readable.push (_stream_readable.js:136:10)
at onread (fs.js:1938:12)
at FSReqWrap.wrapper [as oncomplete] (fs.js:629:17)
I would like to know what's going on ?
via Gatsbill
No comments:
Post a Comment