I'm using the following code to get to access the device Photo Library, however it is retuning base64 encoded string, so I am a bit confused on what to do with this information. I would like to store the photo to the application storage directory (not the device photo album) then get the image URL so I can add it to the user DB.
takePhoto() {
console.log('take photo')
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
console.log(imageData)
let base64Image = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
console.log('camera error')
console.log(err)
});
}