How To Download File To Download's Directory With Ionic Framework?
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
Solution 1:
cordova.file.externalRootDirectory + '/Download/' + 'sample.pdf'
instead of directory.root.nativeURL + 'sample.pdf'
Solution 2:
I solved it via the following code:
constROOT_DIRECTORY = 'file:///sdcard//';
const downloadFolderName = 'Download';
this.file.createDir(ROOT_DIRECTORY, downloadFolderName, true)
.then((entries) => {
//then your code
fileTransfer.download(fileLocation,this.ROOT_DIRECTORY+this.downloadFolderName+'/'+ 'sample.pdf').then((entry) => {
}
//ends of your code ^^
})
.catch((error) => {
alert('error' + JSON.stringify(error));
});
Post a Comment for "How To Download File To Download's Directory With Ionic Framework?"