1 year ago
#330660
Andrea Vannucchi
Cordova File Transfer download ENOENT error
I have to manage and update an old Cordova project, that used File Transfer Plugin for Android platform.
The download functionality is not working and i get this error:
exception: "/storage/emulated/0/Android/data/com.package.name/files/img.jpg: open failed: ENOENT (No such file or directory)"
My download function is:
function downloadFile(remotepath,localpath,filename,r){
var fileTransfer = new FileTransfer();
var uri = encodeURI(remotepath+filename); // https://example.com/download/img.jpg
var local = localpath+filename; // /storage/emulated/0/Android/data/com.package.name/files/img.jpg
fileTransfer.download(
uri,
local,
function(entry) {
entry.getMetadata((metaData) => {
console.log("download complete: " + entry.toURL());
r(metaData.size);
});
},
function(error) {
console.log(error);
}
);
}
It seems working only if target file already exists, otherwise I get ENOENT 'no such file or directory' error. Permissions for read and write storage are granted.
android
cordova
cordova-plugins
file-transfer
0 Answers
Your Answer