@Junek wrote:
Bug Report
Problem
What is expected to happen?
I expected camera plugin to return BASE64 data so I can send it and save it on server.
What does actually happen?
On device, this.camera.getPicture(options) fails with error message:
Cannot read property ‘present’ of undefined
Same thing happens if I use CAMERA or PHOTOLIBRARY as sourceType
Command or Code
imported
import { Camera } from '@ionic-native/camera/ngx';
injected in constructor
constructor(public camera: Camera) { }
and then used in my upload() method
let options = { quality: 100, destinationType: this.camera.DestinationType.DATA_URL, encodingType: this.camera.EncodingType.JPEG, mediaType: this.camera.MediaType.PICTURE, sourceType: this.camera.PictureSourceType.CAMERA, saveToPhotoAlbum: false, correctOrientation: false }; this.camera.getPicture(options).then((imageData) => { let base64Image = 'data:image/jpeg;base64,' + imageData; this.sendToServer(base64Image); }).catch(err => { console.log(err.message); });
Environment, Platform, Device
Not depending on device, happened on multiple devices wit different versions, eg.
Xiaomi Mi 8 - Android 10
Samsung Galaxy A3 - Android 6Version information
Ionic 5.4.16
Cordova: 9.0.0 (cordova-lib@9.0.1)
cordova-plugin-camera 4.1.0 “Camera”
Posts: 1
Participants: 1