The method:
echo VERY_LARGE_STRING | gzip | base64 -w0
.. is limited by linux setting :
getconf ARG_MAX
Used the below and saved my day. Many thanks to Karthik1234
cat <file-name> | gzip | base64 -w0
Here is how we unzip in C# the message compressed in linux
Note: You may need to remove the last byte.
static byte[] Decompress(byte[] gzip)
{
// Create a GZIP stream with decompression mode.
// ... Then create a buffer and write into while reading from the GZIP stream.
using (GZipStream stream = new GZipStream(new MemoryStream(gzip),
CompressionMode.Decompress))
{
const int size = 4096;
byte[] buffer = new byte[size];
using (MemoryStream memory = new MemoryStream())
{
int count = 0;
do
{
count = stream.Read(buffer, 0, size);
if (count > 0)
{
memory.Write(buffer, 0, count);
}
}
while (count > 0);
return memory.ToArray();
}
}
}