I cant upload image with ionic native camera, while using real device


#1

Helloo guys, i try to upload an image using ionic native camera, but it cannot be uploaded while iam using it on real device, when iam running ionic cordova build android and debug on it.

heres my code :

let options: CameraOptions = {
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) => {
console.log(‘ini image dataaaa’,imageData)
let base64Image = ‘data:image/jpeg;base64,’ + imageData;
this.userPhoto = base64Image;
let loader = this.loadCtrl.create({
content: “Uploading…”,
});
loader.present();
let data = {
userId: this.userData.userId,
userPhoto: this.userPhoto
}
console.log(data,‘untuk di upload’)
this.userService.changePicture(data).subscribe(res => {
console.log(res)
loader.dismiss();
})
}, (err) => {
console.log(err)
// Handle error
});
}

but when iam using ionic cordova run browser , it run well and the imaged was uploaded, any idea?