Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

522
Vistas
Read zip file content before unziping in React Native

I am currently developing an app in React Native that handles files and some of them are zip.

I already managed to unzip files using "react-native-zip-archive".

Some of the zip file contain html files that needs unzipped to be displayed and some other are just some random zip files that the user can download.

My problem is that I would like to know the content of the zip file (like a list of the contained files) before unzipping it so that I can unzip only the zip files with html files inside.

Does anyone know a way I can achieve that in React-Native?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

There is a tool called node-stream-zip.

It can extract AND read zip files.

https://github.com/antelle/node-stream-zip

 import {StreamZip} from 'node-stream-zip';

    //Will return true if the zip contains html
    const containsHTML = async (file) => 
    {
    const zip = new StreamZip.async({ file: file });

    const entriesCount = await zip.entriesCount;
    console.log(`Entries read: ${entriesCount}`);
    
    const entries = await zip.entries();
    let found = false;
    for (const entry of Object.values(entries)) {
        if(entry.name.endsWith(".html") found = true; break; //We found the html
      }
    // Do not forget to close the file once you're done
    await zip.close();
    return found;
    
    
    }
about 4 years ago · Juan Pablo Isaza Denunciar

0

There is a tool called node-stream-zip.

This would be a good solution to my problem, but this is a nodeJS lib and it seems that using it in React-Native will not work.

Using node-stream-zip in my react-native app produces this error:

[Error: undefined Unable to resolve module fs from node_stream_zip.js: fs could not be found within the project or in these directories: node_modules let fs = require('fs');]

Here is my code:

import ReactNativeBlobUtil from "react-native-blob-util";
import StreamZip from "node-stream-zip";

const fileName = "zipFile.zip";

const App = () => {

useEffect(() => {
    const start = async () => {
        let dirs = ReactNativeBlobUtil.fs.dirs;
        await initCopyFromAsset();

        const zip = new StreamZip.async({ file: dirs.DocumentDir + "/" + fileName });

    };

    start();
}, []);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda