Skip to content
Discussion options

You must be logged in to vote

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 })

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Touffy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #60 on May 14, 2023 22:05.