Question

I am pretty sure of the answer but I would like someone to confirm it please.

There is no way to unzip only a part of a file when gzip is used in the HTTP headers. I gotta download the whole file before to be able to unzip it to get the data.

Right ?

For example, if I get the first 100 bytes with some code like that:

myfile.read(100)

I won't be able to unzip it at this point.

Thanks.

Was it helpful?

Solution

You can start decompressing a gzip stream immediately, for whatever amount of data you have so far. You will be able to extract all of the uncompressed bytes represented in the compressed data you have available so far.

You must always decompress from the beginning. So what you can't do is start decompressing in the middle of a gzip stream. If you want to access data in the middle, you need to decompress all of the data up to that point.

OTHER TIPS

Wrong. GZIP allows streaming. You might be confusing the format with the ZIP archive format.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top