Check if zip file valid before unzip


#1

Hi all ! Could someone suggest please … is it possible to check zip file on valid before unzip ? Broken zip crash app …


#2

How are you unzipping the zip?


#3

Sujan12, good day ! I have a problem when zip file not valid … I do not get into the error that I can catch …

this.zip.unzip(this.filePath, context.modelsPath + '/' + model_ext_id, (progress) => {
}).then((result) => {
  if (result === 0) console.log('SUCCESS');
  if (result === -1) {
    console.log('FAILED');
    reject({text: "error  unzipping: ", error: result, });
  }
});

#4

I understood that. Please read my question.

Where does this come from? What library is this?


#5

Sujan12, ionic native


#6

Unfortunately problem did not solve … I am trying this, but when zip file is broken error did not catch and app crash …

        this.zip.unzip(this.filePath, this.modelsPath + '/' + model_ext_id, (progress) => {
          this.unzippingSize = Math.round(((progress.loaded / progress.total) * 100));
        }).then((result) => {

          if (result === 0) console.log('SUCCESS');
          if (result === -1) console.log('FAILED');

        });
      }

#7

Did you create an issue at https://github.com/MobileChromeApps/cordova-plugin-zip/issues, the Cordova plugin you are using via Ionic Native?


#8

Sujan12, yes, I open issue …


#9

Are you talking about iOS or Android by the way? Or something else?


#10

Sujan12, now I am only working with Android …


#11

Can you wrap this in a try/catch?


#12

rapropos, could you show example please ?