current position:Home>The front-end downloads files, and the back-end sends gzip files. Is there a way to get the file size?

The front-end downloads files, and the back-end sends gzip files. Is there a way to get the file size?

2022-04-29 17:45:25segmentfault

image.png
Download files from the front end , From the back end is gzip Type of , Is there any way to get this file size ?
Because you need to download the progress bar .



Other answers 1:

If the server does not return content-length You can't make a download progress bar with progress tips , Whether or not gzip resources , Because you can't know in advance how big the resources are .

Refer to the browser when downloading, there is no centent-length Only download speed and current download size are available for resource download , No percentage display .

Not all resources can be returned to you conent-length Of , For streaming data, there is basically no such header , You have to consider this scenario


Other answers 2:

copyright notice
author[segmentfault],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/115/202204251143337118.html

Random recommended