Change Log:
- 2020-04-11: add the
Issue
part
1. Basic
graph LR S3 -->|read stream| ZIP ZIP -->|write stream| DownloadAPI
- S3 file produce a readable stream
- combine multiple readable stream into one zip stream
- transform writeable stream to api for download
2. Research
Does S3 support stream reading?
get the signed url to get the response stream
How to combine multiple readable stream in one zip stream?
- combined-stream to combine multiple read stream or use the archiver
append
function with multiple times - archiver
- combined-stream to combine multiple read stream or use the archiver
How to trasnform writable stream as a REST api?
- make zip steram to response directly
- set the response with stream header
More think
- performence
- impact on existing service
3. Code
stream-download-v3.ts:
1 | import http from 'http'; |
How to verify the result:
1 | // step1 start the server |
4. Issue
you can resolve the issue by use PassThrough
or make iteration to a serializer processing.