I am using the cordova-plugin-camera in order to access the camera in my hybrid app.
I need to capture the photo and send it for upload as base64.
When capturing a photo, I can specify the following:
destinationType: Camera.DestinationType.DATA_URL
which returns an image encoded as base64. However, DATA_URL can be very memory intensive and cause app crashes or out of memory errors (as mentioned in the plugin's documentation). Because of this, my app crashes on weaker devices, so using DATA_URL is a no-go. Using the default FILE_URI should solve this problem, but my backend is configured to only accept base64 encoded images.
My question is, is there a way to convert an image from FILE_URI to DATA_URL base64 encoding?
You could download the picture from the
FILE_URIand then you'd have to render the image in a canvas and then from the canvas, get the base64 using thecanvas.toDataURLmethod.