Using http://plugins.cordova.io/#/package/org.apache.cordova.file and plugin installed = org.apache.cordova.file 1.3.3 "File"
I capture a picture and am trying to convert it to base64. The picture location returned (var path below) is "assets-library://asset/asset.JPG?id=ECB406E6-E361-46AA-9282-FEEBDAC170DF&ext=JPG"
At first from the documentation it looked like all I needed is:
// Convert to image URL base64
var fileReader = new FileReader();
fileReader.onloadend = function (data) {
console.log(data.target.result);
};
fileReader.readAsDataURL(path);
The code executed but the callback never fired! I then dug around and added a bunch of other fileReader options... exactly zero of which actually execute. Same behavior on both iOS and Android
fileReader.onload = function (data) {
console.log("onload", data);
};
fileReader.onerror = function (data) {
console.log("error!", data);
};
fileReader.onloadstart = function (data) {
console.log("onloadstart", data);
};
I'm not getting any JS errors, but I'm also not getting any console output.
1) Why are the Cordova File FileReader() callbacks not firing?
Update
I tried using ngCordova's file plugin as well, http://ngcordova.com/docs/plugins/file/
$cordovaFile.readAsDataURL('assets-library://asset/', 'asset.JPG?id=ECB406E6-E361-46AA-9282-FEEBDAC170DF&ext=JPG')
.then(function (success) {
// success
console.log("ng success", success);
}, function (error) {
// error
console.log("ng error", error);
});
With that I receive the following error:
Error in Success callbackId: File1336724899 : TypeError: undefined is not a function (evaluating 'e.getFile')