Skip to content

[HelpWanted] Download progress #71

@jawainc

Description

@jawainc

Hello,
Thanks for the great library.

I am facing problem for displaying the download progress

here's my code:

   const files = response.data.files

    totalBytes = getTotalBytes(files)

    const requests = files.map((file) => fetch(file.url)
      .then(async (response) => {
        const reader = response.body.getReader()
        const chunks = []
        while (true) {
          const { done, value } = await reader.read();
          if (done) {
            break;
          }
          chunks.push(value)
          receivedBytes += value.length;
          progress(receivedBytes)
        }
        return new Blob(chunks) //--> dont know if this is the correct way
      })
      .catch(error => {
        throw new Error(error.message + "\nURL: " + file.url)
      })
    )
    const responses = await Promise.all(requests)
    
    console.log("response: ", responses) //--> this works and output like:  (11) [Blob, Blob, Blob, Blob, Blob, Blob, Blob, Blob, Blob, Blob, Blob]

    const blob = await downloadZip(responses); //--> not working

    const link = document.createElement("a")
    link.href = URL.createObjectURL(blob)
    link.download = fileName + ".zip"
    link.click()
    URL.revokeObjectURL(link.href)
    link.remove()

I've tried solution mentioned here: #19
but it does not calculate when files are downloaded but rather I think when making zip file

Any help on this matter Please

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions