thejoshwolfe / yauzl

yet another unzip library for node
MIT License
678 stars 77 forks source link

Support for gzip #104

Closed AmitMY closed 3 months ago

AmitMY commented 5 years ago

If I try to unzip a zip file it works, but a gzip file fails with:

Error: end of central directory record signature not found

If I manually use winrar for example, the file is not corrupted and works correctly.

AmitMY commented 5 years ago

P.S Gunzip support would not be hard to add. Here is an example:

    const gunzip = zlib.createGunzip();
    fs.createReadStream(this.path).pipe(gunzip);

    return new Promise((resolve, reject) => {
      const buffer = [];
      gunzip
        .on('data', (data) => buffer.push(data.toString()))
        .on('end', () => resolve(buffer.join("")))
        .on('error', (e) => reject(e));
    })
thejoshwolfe commented 3 months ago

yauzl is for zip files. You can test if a file is a zip file by opening it with yauzl and checking for an immediate error or not. How to handle non-zip files is beyond the scope of this library.