I’m using the GZipStream
class from the System.IO.Compression
library to decompress a stream of data. I initialize a MemoryStream
and use the CopyTo
method to copy the decompressed data into it. Despite properly setting the stream’s initial position and initialization, only 8KB of data is being copied and we are exiting from that section of code.
Here’s a simplified version of the code I’m using:
public static void DecompressStream(Stream inputCompressedStream, MemoryStream outputMemoryStream) {
inputCompressedStream.Position = 0;
using (GZipStream decompressionStream = new GZipStream(inputCompressedStream, CompressionMode.Decompress))
{
decompressionStream.CopyTo(outputMemoryStream);
}
}
Problem Details:
-
Issue: The
GZipStream
seems to only copy 8KB of data, which corresponds to only one record from the stream. -
Observation: Despite the stream initialization being correct, the decompression process does not handle more than 8KB of data at a time.
Questions:
- Is there any bug or limitation with GZip stream in .Net Standard 2.0 that could cause this behaviour, if yes can you please point where this has been raised or discussed(maybe Github or something) !
Additional Information:
-
It is a Library and the target framework is .NET Standard 2.0
-
Buffer Size: Default buffer size for
CopyTo
method. -
Data: The compressed data is significantly larger than 8KB.
6