Question

I'm a little confused with the filetransfer method of Cordova for iOS. (I had a version working with Android)

Apparently, I don't set the destination folder properly. target:null Could not create target file Note that I assume that the directory exists as it is created with success earlier in the script.

According to the Cordova documentation, I should use a entry.toURL to get the right path.

function download(filename){
    var localPath = rootFS.toURL+'contentImages/'+filename;
    var fileTransfer = new FileTransfer();
    fileTransfer.download(encodeURI('http://myValidatedSource.com/'+filename),
        localpath,
        function(entry){
            console.log('download completed for '+entry.fullPath);
        },
        function(error){
            console.log(error);
        }
    );
}

I also tried this:

alert(rootFS.fullPath);        ==> "/"

and

alert(rootFS.toURL);           ==> "function(){
                                if (this.nativeURL){
                                   return this.nativeURL;
                                   }
                                return this.toInternalURL()|| "file://localhost"+this.fullPath";
                                }"
Was it helpful?

Solution

I was not so far...

var localPath = rootFS().toURL+'contentImages/'+filename;

instead of

var localPath = rootFS.toURL+'contentImages/'+filename;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top