Would it be possible to delete the Library directory in iOS where I am storing images within my app using the Cordova-plugin-file and Cordova-plugin-file transfer?
Seeking assistance from anyone who can help with this.
This is the code I have for downloading the image:
downloadImage: function(url, fileName) {
var deferred = $q.defer();
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
fs.root.getDirectory(
LOCAL_STORAGE_KEYS.app, {
create: true
},
function(dirEntry) {
// console.log(arguments);
dirEntry.getFile(
fileName, {
create: true,
exclusive: false
},
function(fe) {
console.log(arguments);
var p = fe.toURL();
console.log("In service the url path:", p);
fe.remove();
var ft = new FileTransfer();
console.log('File Transfer instance:', ft);
ft.download(
encodeURI(url),
p,
function(entry) {
console.log('In service the entry callback:', entry);
if (entry && entry.toURL) {
deferred.resolve(entry.toURL());
} else {
console.log('No entry:', arguments);
deferred.resolve();
}
},
function(err) {
console.log('Getting rejected:', err);
deferred.reject(err);
},
false,
null
);
},
function() {
deferred.reject(new Error('get file failed'));
}
);
}
);
},
function() {
deferred.reject(new Error('get directory failed'));
});
return deferred.promise;
}