Giter VIP home page Giter VIP logo

Comments (6)

plrthink avatar plrthink commented on May 26, 2024

Not very sure about what wrong with the first case, since I'm not familiar with native android development, so you can feel free to open a PR to correct this bug.

from react-native-zip-archive.

jr-k avatar jr-k commented on May 26, 2024

Try to mkdir your subfolders of your zip... I know it's weird but it worked for me

from react-native-zip-archive.

hujiudeyang avatar hujiudeyang commented on May 26, 2024

it worked for me
@MadisonBlake
Android => RNZipArchiveModule.java:73

import java.io.BufferedInputStream;
  private void unzipStream(String zipFilePath, String destDirectory, InputStream inputStream, long totalSize, Callback completionCallback) {
    try {
      File destDir = new File(destDirectory);
      if (!destDir.exists()) {
        destDir.mkdirs();
      }

      ZipInputStream zipIn = new ZipInputStream(inputStream);
      BufferedInputStream bin = new BufferedInputStream(zipIn); 
      ZipEntry entry;

      long extractedBytes = 0;

      updateProgress(0, 1, zipFilePath); // force 0%

      File fout=null;
      while((entry = zipIn.getNextEntry())!=null){  
        if(entry.isDirectory()) continue;  
        fout=new File(destDirectory, entry.getName());
        if(!fout.exists()){
          (new File(fout.getParent())).mkdirs();  
        }  
        FileOutputStream out=new FileOutputStream(fout);
        BufferedOutputStream Bout=new BufferedOutputStream(out);
        int b;  
        while((b=bin.read())!=-1){
          Bout.write(b); 
        }
        Bout.close();
        out.close();
      }  
      updateProgress(1, 1, zipFilePath); // force 100%
      bin.close();
      zipIn.close();
      completionCallback.invoke(null, null);
    } catch (Exception ex) {
      ex.printStackTrace();
      updateProgress(0, 1, zipFilePath); // force 0%
      completionCallback.invoke(makeErrorPayload(String.format("Couldn't extract %s", zipFilePath), ex));
    }
  }

from react-native-zip-archive.

plrthink avatar plrthink commented on May 26, 2024

@hujiudeyang There's some formatting issue, can you update the comment to fix it? Also, you can directly make a PR to improve that, which will be very grateful.

from react-native-zip-archive.

 avatar commented on May 26, 2024

Hi, I've been trying to find another solution because this isn't helping, I tried everything I have in mind and it just won't work.
I have the same exact problem, using "react-native": "0.43.3".
If anyone could update this issue it would be grate, thanks!

from react-native-zip-archive.

plrthink avatar plrthink commented on May 26, 2024

@AmatsuZero

from react-native-zip-archive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.