node-unzipper icon indicating copy to clipboard operation
node-unzipper copied to clipboard

Getting error "too many length or distance symbols"

Open ChrisZieba opened this issue 3 years ago • 1 comments

Based on some of the tickets I've seen, extracting a nested zip is possible, but I'm running into this error when attempting:

    Error: too many length or distance symbols
        at Zlib.zlibOnError [as onerror] (zlib.js:168:17)

Here is the parent zip: https://nces.ed.gov/ccd/Data/zip/ccd_sch_052_1718_l_1a_083118.zip. It contains two nested zip structures.

I try to pass the buffer directly to zipper.Open.buffer but that's where I get the error when processing the stream after.

    const buffer = (
      await axios.get(
        'https://nces.ed.gov/ccd/Data/zip/ccd_sch_052_1718_l_1a_083118.zip',
        { responseType: 'arraybuffer' },
      )
    ).data;
    const directory = await unzipper.Open.buffer(buffer);

    const nestedZip = directory.files.find(file =>
      file.path.endsWith('CSV.zip'),
    );

    const innerZip = await unzipper.Open.buffer(await nestedZip.buffer());
    const stream = innerZip.files[0].stream();

   // Do something with inner zip stream ...

Is this not a supported way to extract the nested structure currently? I have also tried parsing the parent, writing the nested zip to disk, and then attempting an unzip that way, but I run into the same issue. Any ideas?

ChrisZieba avatar Jul 10 '21 16:07 ChrisZieba

What if you manually extract the outer ZIP from the command line or something and try to use unzipper to read the inner ZIP?

The fact that the ZIP file comes from another ZIP file shouldn't make any difference, as you never told the unzipper that it originally got that buffer from another unzipper.

Maybe it's just something about the inner ZIP file that is causing problems.

dobesv avatar Jul 14 '21 19:07 dobesv