var fileTransfer = new FileTransfer(); var uri = encodeURI(source); fileTransfer.download(uri,filePath, function (entry) { // success }, function (error) { // error }, trustAllHosts, options);
if you want to use it with $cordovaCamera.getPicture(), you will need to resolve FILE_URI first, and use it as source.
1 2 3 4 5 6 7 8 9
function getImageFileName(image) { window.resolveLocalFileSystemURL(image, function(entry) { var uri = entry.toURL(); entry.file(function(file) { var fileName = file.name; }); }); }
another problem is filepath.
basePath can find it by below code. and filepath need a filename at the end.
1 2 3 4 5 6
$cordovaFile.createDir(directory, false).then(function(entry) { // Success! alert(entry.toURL()); }, function(err) { // An error occured. Show a message to the user });
Since getUsers() returns a new array, Angular determines that the model is different on each $digest cycle, resulting in the error. The solution is to return the same array object if the elements have not changed:
// set item val window.localstorage.setItem(key,value); window.localstorage.getItem(key); window.localstorage.removeItem(key); window.localstorage.clear();