Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

362
Views
¿Cómo puedo verificar si un archivo zip está dañado en NodeJS?

Verificaría si un archivo ZIP está dañado usando NodeJS usando menos CPU y memoria como sea posible.

Cómo corromper un archivo ZIP:

  1. Descargar un archivo ZIP
  2. Abra el archivo ZIP usando un editor de texto optimizado como Notepad++
  3. Reescribe el encabezado. Solo pon caracteres aleatorios.

Estoy tratando de alcanzar este objetivo usando la biblioteca NPM "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(); } }

Sin embargo, cuando ejecuto las pruebas unitarias, recibo un error dentro de una matriz:

Rechazado al valor: [Error]

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

import zip from 'yauzl'; import path from 'path'; const invalidZipPath = path.resolve('invalid.zip'); const validZipPath = path.resolve('valid.zip'); const isValidZipFile = (filePath) => { return zip.open(filePath, { lazyEntries: true }, (err, stream ) => { if (err) { console.log('fail to read ', filePath); return false; } console.log('success read ', filePath); return true; }); } isValidZipFile(validZipPath); isValidZipFile(invalidZipPath);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!