Ionic 3 Camera plugin problem

#1

i have issue when i use the plugin and try to decode the img in the base64

My code

getimage(Type){
let options: CameraOptions;
if (Type == ‘camera’) {
options = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE

};
} else if (Type == ‘gallery’) {
options = {
sourceType: this.camera.PictureSourceType.SAVEDPHOTOALBUM,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE

};

}

this.camera.getPicture(options).then((img) => {
let base64 = ‘data:image/jpeg;base64,’ + img;
let data = {
token : this.api.token,
picture: base64

}
this.loading = this.loadingCtrl.create({
content: <ion-spinner name="bubbles" ></ion-spinner> Chargement...
});
this.loading.present();
this.api.post(‘media/upload’,data).toPromise().then((res) => {
this.loading.dismiss();

if (res[‘status’] == 200) {
let alert = this.alertCtrl.create({
title: ‘Information’,
subTitle: ‘Image ajouté avec succès’,
buttons: [{text:‘OK’}]
});
alert.present();
}else
{
let alert = this.alertCtrl.create({
title: res[‘status’],
buttons: [‘Ok’]
});
alert.present();
}
}).catch((e) => {
let alert = this.alertCtrl.create({
title: e.message,
buttons: [‘Ok’]
});
alert.present();
});
});
}

#2

Can you put this information into a repo you could share?

#3

@Judgewest2000 how can i do this ? i am new here

#4

That’s a repo I put together a while back which is a working implementation of the camera. Have a look at that and let me know what you thinkg.

REPO
This is also a minimal repo highlighting the actual functionality. If someone asks you to put together a repo - the idea is the repo should contain ONLY the code in question, and that code should not be linked to any outside resource not available to the helper - i.e. Remote API