Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't extract but success OK #7

Open
sadikyalcin opened this issue Sep 28, 2017 · 0 comments
Open

Doesn't extract but success OK #7

sadikyalcin opened this issue Sep 28, 2017 · 0 comments

Comments

@sadikyalcin
Copy link

sadikyalcin commented Sep 28, 2017

I'm not clear on how this plugin supposed to work but it clearly fails to extract the zip. Here is my code;

download: function(){

        app.downloadZip('1535',
            function _onProgress(fileDownloader) {
                console.log('Progress: ', fileDownloader);
/*
                var downloadProgress = parseFloat(fileDownloader.downloadProgress);
                downloadProgress =  Math.round(downloadProgress * 100);
                console.log('Progress: ', downloadProgress);
*/
            },
            function _onSuccess(entry) {
                console.log('Entry: ', entry);


                presenter.fileSystem.createDirectory(config.appDirName + '/1535',
                    function __onSuccess() {
                        console.log('Done!');
                        app.extract(entry);
                    },
                    function __onError(error) {
                        onError(error);
                    }
                );

            },
            function _onAbort() {
            },
            function _onError(error) {
                console.log('error: ', error);
            }
        );
    },

downloadZip: function(zip, onProgress, onSuccess, onAbort, onError) {

        var url = 'http://companyapp.co.uk/1535.zip';

        app.fileDownloader.remoteURL = url;
        app.fileDownloader.localFilePath = config.appDirName + '/' + '1535.zip';
        app.fileDownloader.bytesToDownload = '2435379';

        app.fileDownloader.download(options = { trustAllHosts: true},
            function _onProgress() {
                onProgress(presenter.fileDownloader);
            },
            function _onSuccess(zip) {
                onSuccess(zip);
            },
            function _onAbort() {
                onAbort();
            },
            function _onError(error) {
                onError(error);
            }
        );
    }

extract: function(entry){

      var zip = entry.nativeURL;
      var extracted = entry.name.split('.');
          extracted = extracted['0'];

      var fs = presenter.fileSystem.getFS();

      fs.root.getDirectory(config.appDirName + '/' + extracted, { create: false },
          function(presFolder){
              console.log(presFolder);
              Zeep.unzip({
                  from : zip,
                  to   : presFolder.nativeURL
              }, function(e) {
                  console.log('success: ', e);
                  // print out: success:  OK
              }, function(e) {
                  console.log('error: ', e);
              });
          },
          function(e){
              console.log(e)
          }
      );
    },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant