-
Notifications
You must be signed in to change notification settings - Fork 759
Closed
Description
Bug Report
Reading a file works on Android. It fails on iOS 13.5.1 with error code 1.
The code I'm using:
function getLocalFile(url, cb) {
console.log("ATTEMPTING TO LOAD: ",cordova.file.applicationDirectory + "www/"+url);
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + "www/"+url, function(fileEntry) {
console.log(fileEntry);
fileEntry.file(function(file) {
var s = "";
s += "<b>name:</b> " + file.name + "<br/>";
s += "<b>localURL:</b> " + file.localURL + "<br/>";
s += "<b>type:</b> " + file.type + "<br/>";
s += "<b>lastModifiedDate:</b> " + (new Date(file.lastModifiedDate)) + "<br/>";
s += "<b>size:</b> " + file.size + "<br/>";
console.log(s);
var reader = new FileReader();
reader.onloadend = function() {
var fileContents = this.result;
console.log("Successful file read: "+fileContents);
if(cb) cb(fileContents);
};
reader.readAsText(file);
});
}, function(err) {
console.log("File failed ", err);
console.dir(err);
});
}
Also works on Android, but fails on iOS:
function getLocalFile(url, cb) {
resolveLocalFileSystemURL(cordova.file.applicationDirectory, function(entry) {
console.log("Success! Got a app dir");
console.log(entry);
var nativeURL = entry.nativeURL;
console.log("NATIVE URL IS ",nativeURL);
console.log("ATTEMPTING TO LOAD: ",nativeURL + "www/"+url);
window.resolveLocalFileSystemURL(nativeURL + "www/"+url, function(fileEntry) {
console.log("FILE ENTRY INFORMATION IS: ");
console.log(fileEntry);
fileEntry.file(function(file) {
var s = "";
s += "<b>name:</b> " + file.name + "<br/>";
s += "<b>localURL:</b> " + file.localURL + "<br/>";
s += "<b>type:</b> " + file.type + "<br/>";
s += "<b>lastModifiedDate:</b> " + (new Date(file.lastModifiedDate)) + "<br/>";
s += "<b>size:</b> " + file.size + "<br/>";
console.log(s);
var reader = new FileReader();
reader.onloadend = function() {
var fileContents = this.result;
console.log("Successful file read: "+fileContents);
if(cb) cb(fileContents);
};
reader.readAsText(file);
});
}, function(err) {
console.log("File failed ################# ", err);
console.dir(err);
});
}, function(error) {
console.error("Something bad happened, and we didn't get a app dir");
});
}
What is expected to happen?
Both platforms return same result.
What does actually happen?
Returns error code 1.
Environment, Platform, Device
Physical iPhone X, iOS 13.5.1
Version information
cordova-plugin 6.0.2
Phonegap 9
iOS 13.5.1
Xcode for building
Checklist
- I searched for existing GitHub issues
- I updated all Cordova tooling to most recent version
- I included all the necessary information above
Metadata
Metadata
Assignees
Labels
No labels