Touffy / client-zip

A client-side streaming ZIP generator
MIT License
351 stars 22 forks source link

[Question]: Does client-zip work with streamsaver ? #17

Closed owpac closed 3 years ago

owpac commented 3 years ago

Hello !

First of all, thank you for your work. I'm not a pro but I couldn't manage to use client-zip with streamsaver ? I'm not sure if this is because it's not the purpose of your lib or if i'm wrong somewhere. If there is a way to do it, could you help me with a small code snippet please ?

Thanks

Touffy commented 3 years ago

Well, I didn't test it but it should work. downloadZip returns a Response, so that has a body property which is a ReadableStream. StreamSaver should be happy with that. Can you post the code you tried ?

This should work :

const { body } = downloadZip(/* your input */)

const fileStream = streamSaver.createWriteStream(/* StreamSaver options */)

body.pipeTo(fileStream)
owpac commented 3 years ago

Ok so you are right, everything work fine with your example ! I was doing it the wrong way... Thanks again for your work !