Im using the ngCordova camera API and sending an image up to an image recognition service. This needs to be sent as FILE_URI. But then after it has been sent, I need to convert it to base64 to store it somewhere else.
Im having trouble doing so, I tried using the FileReader - but that doesnt seem to work.
I just tried attached two functions to ng-click, but it only fires the camera once. Im stuck and not sure what else to do!
Hey there! It’s hard to tell exactly what could be going wrong, but it sounds like you’re trying to do something like this at a high level:
$cordovaCamera.getPicture(options)
.then(function(imageData){
// send image to third party image service
return imageData
})
.then(function(imageData){
// image was sent to third party service
// convert to base64 and save
});
From here, you can actually encode images to base64 using html5 canvas - no server required. Here’s a post that shows how this is done. If you’re still working through this, perhaps you could upload your code to codepen and I can check it out?