Rohit Gaikwad
Rohit Gaikwad

Reputation: 1

How to download Folder using Cordova fileTransfer to android or Ios device

I am really new to Ionic so this might be a simple one but i don't know it yet.So please help
I want to download a folder from Google drive to Android /Ios from my app and use it in app. I thought i can use the same code which is used to download a normal file but it's not working.

Code i am using is ---

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, 

function(directory) {
          var fileTransfer = new FileTransfer();
          console.log(directory.root);
          fileTransfer.download(
              encodeURI("https://drive.google.com/open?id=0B6tGuVQgFM6vM1Rjelsdadadaas"),
              directory.root.nativeURL +  'course1',
              function(entry) {
                  console.log("download complete: " + entry.fullPath);
                  },
              function(error) {
                  console.log(error);
                  console.log("download error source " + error);
                  console.log("download error target " + error.target);
                  console.log("upload error code" + error.code);
              },
              false
          );
      }, function(err){console.error(err)}); 

I am not getting any error but don't see any new file inside my project name/files/ folder in my android device.

Please help and i want to download a full folder /or if is it good to download a zip and unzip it to some location?/

Please suggest.

Thanks in advance

Upvotes: 0

Views: 282

Answers (1)

Shubham Chaudhari
Shubham Chaudhari

Reputation: 33

You can not download a folder using CordovaFileTransfer. You need to keep the folder in zip or tar format and then you can download it.

Upvotes: 0

Related Questions