mockingbot / react-native-zip-archive

Zip archive utility for react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unzip file with expo

RobinAlonzo opened this issue · comments

I use expo to run my IOS and Android applications.
I want to use the react-native-zip-archive lib but as soon as I try to run my code I get this error

[TypeError: Cannot read property 'unzip' of null]

Does anyone have a solution?

const downloadAndExtractZip = async () => {
  try {
    // Définition des variables
    const zipUrl = "URL_DU_SITE";
    const fileUri = FileSystem.documentDirectory + "Chupaca.zip";
    const destinationDirectory = FileSystem.documentDirectory + 'maps/';
    const charset = "UTF-8";

    // Vérification de l'existence du fichier ZIP
    const fileInfo = await FileSystem.getInfoAsync(fileUri);

    if (fileInfo.exists) {
      const files = await FileSystem.readDirectoryAsync(FileSystem.documentDirectory);
      console.log('Contenu du répertoire :', files);
    }

    // Téléchargement du fichier ZIP
    const downloadFile = await FileSystem.downloadAsync(zipUrl, fileUri);

    if (downloadFile.status === 200) {
      console.log('Téléchargement du fichier ZIP terminé.')

      // Extraction du fichier ZIP
      console.log('Extraction du fichier ZIP...' + fileUri)
      await unzip(fileUri, destinationDirectory, charset)
      console.log('Extraction du ZIP terminée.');
    } else {
      console.log('Erreur lors du téléchargement du fichier ZIP.');
    }
  } catch (error) {
    console.error('Erreur lors de la récupération du fichier ZIP :', error);
  }
  ;
};

// Utilisation de la fonction pour télécharger et extraire le fichier ZIP
downloadAndExtractZip();

Do you have the solution? I am also getting the same problem.....
@plrthink is there any solution for expo?

Guys you have to npx expo install this library to ensure expo obtains the compatible version for your project and then build it using the eas-cli since this is not a part of the Expo library it will not work with Expo apps on the fly. What you need to do is search up how to build custom dev clients with expo and your problem will be solved. @Abdullah-Mazumder @RobinAlonzo

@plrthink, @Abdullah-Mazumder Have you found any solutions to it?

@plrthink, @Abdullah-Mazumder Have you found any solutions to it?

Yes. You have to use development build to test your app.expo go will not work with this package

commented

This issue should be closed if the above solves the issue. It's not going to work on Expo Go.

Since expo is recommended by the react-native team, its support should be prioritized more highly. But I'm not familiar with it and don't have enough time, so I'm hoping someone could take this on.