Closed shiliuxiaoler closed 2 years ago
figuring out the final total size of multiple url from content-length and extra zip headers can be tuff...
// example
res = await fetch('https://httpbin.org/gzip')
blob = await res.blob()
console.log(res.headers.get('content-encoding')) // gzip
console.log(res.headers.get('content-length')) // 482
console.log(blob.size) // 880
fixed_size * n_files + all_file_names_in_utf8array.bytelength + end_of_central_zip_size
predicting the total file size in advance is hard. it's something i would recommend against. Instead of would add a html UI showing the progress of each file that is being downloaded. and how many files there are left.
something like:
- file_a.txt - 100% - done
- file_b.txt - 100% - done
- file_c.txt - 80% - downloading
- file_d.txt - 0% - pending
- file_e.txt - 0% - pending
you can't update the content-size after the download has started unfortunately
I want to display the total size of the compressed package file during the process of downloading large files, but the totalSize of all files has not been obtained when createWriteStream is created. How to update the size of createWriteStream after fetching to get all Content-Length? I've tried many ways to no avail, I hope to get help, thank you so much.