StreamPeerGZip
A stream peer that handles GZIP and deflate compression/decompression.
A stream peer that handles GZIP and deflate compression/decompression.
This class allows to compress or decompress data using GZIP/deflate in a streaming fashion. This is particularly useful when compressing or decompressing files that have to be sent through the network without needing to allocate them all in memory.
After starting the stream via StreamPeerGZip.StartCompression (or StreamPeerGZip.StartDecompression), calling StreamPeer.PutPartialData on this stream will compress (or decompress) the data, writing it to the internal buffer. Calling StreamPeer.GetAvailableBytes will return the pending bytes in the internal buffer, and StreamPeer.GetPartialData will retrieve the compressed (or decompressed) bytes from it. When the stream is over, you must call StreamPeerGZip.Finish to ensure the internal buffer is properly flushed (make sure to call StreamPeer.GetAvailableBytes on last time to check if more data needs to be read after that).
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
StreamPeerGZipConstructor
public StreamPeerGZip();Methods4
Clearvoid
public void Clear();Clears this stream, resetting the internal state.
FinishError
public Error Finish();Finalizes the stream, compressing any buffered chunk left. You must call it only when you are compressing.
ErrorStartCompressionError
public Error StartCompression(bool useDeflate = false, int bufferSize = 65535);Start the stream in compression mode with the given buffer_size, if use_deflate is true uses deflate instead of GZIP.
| Name | Type | Default |
|---|---|---|
useDeflate | bool | false |
bufferSize | int | 65535 |
ErrorStartDecompressionError
public Error StartDecompression(bool useDeflate = false, int bufferSize = 65535);Start the stream in decompression mode with the given buffer_size, if use_deflate is true uses deflate instead of GZIP.
| Name | Type | Default |
|---|---|---|
useDeflate | bool | false |
bufferSize | int | 65535 |
Error