# Problems decompressing zip file from binary data using GZIPDecompressorInputStream

**URL:** <https://forum.juce.com/t/problems-decompressing-zip-file-from-binary-data-using-gzipdecompressorinputstream/57972>\
**Category:** General JUCE discussion\
**Created:** [September 21, 2023, 2:45pm UTC](https://forum.juce.com/t/problems-decompressing-zip-file-from-binary-data-using-gzipdecompressorinputstream/57972 "2023-09-21T14:45:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PluginPenguin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/pluginpenguin/32/10203_2.png) [@PluginPenguin](https://forum.juce.com/u/PluginPenguin)\
**Post date:** [September 21, 2023, 2:45pm UTC](https://forum.juce.com/t/problems-decompressing-zip-file-from-binary-data-using-gzipdecompressorinputstream/57972/1 "2023-09-21T14:45:06Z")

</div>

I have a larger json file that has been zipped using the macOS finder embedded as binary data. Now I want to use `juce::GZIPDecompressorInputStream` to decompress it. The output of

```auto
file bigFile.json.zip

```

in the terminal is

```auto
bigFile.json.zip: Zip archive data, at least v2.0 to extract, compression method=deflate

```

My approach on decompressing looks as straightforward as this:

```auto
juce::MemoryInputStream zippedStream (BinaryData::bigFile_json_zip, BinaryData::bigFile_json_zipSize, false);
juce::GZIPDecompressorInputStream decompressedStream (& zippedStream, false, juce::GZIPDecompressorInputStream::Format::deflateFormat);

juce::MemoryBlock json;
decompressedStream.readIntoMemoryBlock (json);

```

However this results in a memory block of size zero. Under the debugger I see that `GZIPDecompressHelper::error` in the stream is true, so I assume this is because of some error occurring. However there is no further error reporting, no assertion (which I find extremely untypical for a JUCE class by the way) so I have no clue what’s going wrong here.

I have chosen `Format::deflateFormat` based on the output of the `file` command but I also tried `Format::zlibFormat` with a similar result. I have basically no knowledge about zip file format details, so I’m not sure if for some reasons the file format generated by the finder is incompatible with the JUCE implementation.

Has anyone achieved decompressing a file compressed on macOS successfully before and can share some insights on how to do it or at least how to get some insight about what’s going wrong?

---

<div class="post-metadata">

**Author:** ![PluginPenguin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/pluginpenguin/32/10203_2.png) [@PluginPenguin](https://forum.juce.com/u/PluginPenguin)\
**Post date:** [September 21, 2023, 2:58pm UTC](https://forum.juce.com/t/problems-decompressing-zip-file-from-binary-data-using-gzipdecompressorinputstream/57972/2 "2023-09-21T14:58:00Z")

</div>

Nevermind, found the solution myself and it’s pretty embarrassing 😃

GZip is not Zip. Well, should have done some really basic research before posting, but still leaving it here for others that might come across the same problem 😉 When using a gzip compressed file, everything works as expected. And I think `juce::ZipFile` is the right tool for handling a Zip.

Problem solved!

---

<div class="post-metadata">

**Author:** ![MBO](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mbo/32/5045_2.png) [@MBO](https://forum.juce.com/u/MBO)\
**Post date:** [September 21, 2023, 5:10pm UTC](https://forum.juce.com/t/problems-decompressing-zip-file-from-binary-data-using-gzipdecompressorinputstream/57972/3 "2023-09-21T17:10:18Z")

</div>

If I remember correctly, `juce::ZipFile` uses internally `GZIPCompressorOutputStream` and `GZIPDecompressorInputStream`, so also GZip instead of Zip…
