in

How could I check If a zip file is corrupted in NodeJS?


I would check if a ZIP file is corrupted using NodeJS using less CPU and memory as possible.

How to corrupt a ZIP file:

  1. Download a ZIP file
  2. Open the ZIP file using a text editor optimized like Notepad++
  3. Rewrite the header. Only put random characters.

I am trying to reach this goal using the NPM library “node-stream-zip”

  private async assertZipFileIntegrity(path: string) {
    try {
      const zip = new StreamZip.async({ file: path });
      const stm = await zip.stream(path);
      stm.pipe(process.stdout);
      stm.on('end', () => zip.close());
    } catch (error) {
      throw new Error();
    }
  }

However, when I run the unit tests I receive an error inside an array:

Rejected to value: [Error]



Source: https://stackoverflow.com/questions/70722225/how-could-i-check-if-a-zip-file-is-corrupted-in-nodejs

What to use in place of Loggerfactory while migrating from log4j1 to log4j2

Netcup provider implementation for libdns