Closed StavrosHacker closed 1 year ago
Absolutely. We get a Response as usual, and instead of yielding it by itself, we put it in an object with its desired filename:
async function *lazyFetch() {
for (const { name, input } of files) yield { name, input: await fetch(input) }
}
I didn't copy the 'size' property because it doesn't do anything when actually making the Zip. You can pass your original files
array in the metadata
option, so that downloadZip
will set the correct Content-Length header (assuming your sizes are accurate, of course) :
const zipResponse = downloadZip(lazyFetch(), { metadata: files })
I've been using client-zip on deno to zip-on-the-fly some files on my origin server using the following code:
However with this way I cannot put files in different folders.
I would like to be able to have an array with an object for each file, for example:
and lazyfetch it. Is this doable?
Thank you.