I was not so far...
var localPath = rootFS().toURL+'contentImages/'+filename;
instead of
var localPath = rootFS.toURL+'contentImages/'+filename;
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";
}"
Solution
I was not so far...
var localPath = rootFS().toURL+'contentImages/'+filename;
instead of
var localPath = rootFS.toURL+'contentImages/'+filename;