I am now developing a cordova app which platform is browser.
I need to access a text file from local file system, so I am using the cordova-plugin-file.
But I failed as the exception in my chrome console like this (There is no CLI error):
code: 5
message: "A URI supplied to the API was malformed, or the resulting Data URL has exceeded the URL length limitations for Data URLs."
name: "EncodingError"
as my code blow:
document.addEventListener('deviceready', dataRead, false);
function dataRead() {
window.webkitRequestFileSystem(window.PERSISTENT, 100500*1024*1024, function() {
window.webkitResolveLocalFileSystemURL("filesystem:" + cordova.file.applicationDirectory + "1111.csv", gotFile, fail);
},function (e) {
console.log(e);
});
}
function fail(e) {
console.log("FileSystem Error");
console.dir(e);
}
function gotFile(fileEntry) {
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
console.log("Text is: "+this.result);
}
reader.readAsText(file);
});
}
Is my URI illegal or for some other reasons?
Can anybody point out why? Or show me a right example.
Any help is appreciated.