I'm trying with ngCordova
but the cordova.file.documentsDirectory
property is null
.
I have also tried combining the use of ngCordova
with requestFileSystem
, but still, the file is not saved in the "Download's".
Example of my code:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(directory) {
var fileTransfer = new FileTransfer();
fileTransfer.download(
encodeURI("http://example.com/sample.pdf"),
directory.root.nativeURL + 'sample.pdf',
function(entry) {
console.log("download complete: " + entry.fullPath);
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
false
);
}, function(err){console.error(err)});
Thanks.
cordova.file.externalRootDirectory + '/Download/' + 'sample.pdf'
instead ofdirectory.root.nativeURL + 'sample.pdf'
I solved it via the following code: