Closed gizahNL closed 1 year ago
You can get a pair of readable and writable streams from a transform stream.
const { readable, writable } = new TransformStream();
(async () => {
for (const body of responseBodies) {
await body.pipeTo(writable, { preventClose: true });
}
await writable.close();
})();
await zipWriter.add("concatenated_files", { readable });
Thanks, I think that should work :)
Note that you should be able to pass also an Array of ReadableStream
(or Reader
) instances to ZipWriter#add()
. See below for example.
Is it possible to create a WritableStream when adding a file?
I have a ton of ReadableStreams (from response.body) that need to be concatted into a single file that needs to be made part of a zip. Having a WritableStream would allow me to simply pipe my readable streams into the file.