Im having trouble displaying the photo taken in a view
my setup is:
global packages:
@ionic/cli-utils : 1.5.0
Cordova CLI : 7.0.1
Ionic CLI : 3.5.0
local packages:
@ionic/app-scripts : 1.3.12
@ionic/cli-plugin-cordova : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms : ios 4.3.1
Ionic Framework : ionic-angular 3.4.2
System:
Node : v6.11.1
OS : macOS Sierra
Xcode : Xcode 8.2.1 Build version 8C1002
ios-deploy : not installed
ios-sim : not installed
npm : 5.3.0
For the photo im using the next code:
base64Image: string[] = [];
takePicture(){
const options: CameraOptions = {
quality: 80,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: this.camera.PictureSourceType.CAMERA,
};
this.camera.getPicture(options)
.then((imageData) => {
if (this.flag == false) {
this.base64Image.push('data:image/jpeg;base64,' + imageData);
}else{
this.base64Image.push('data:image/jpeg;base64,' + imageData);
this.buttonFlag=true;
}
this.countFlag = true;
})
.catch((err) => {
console.log(err);
this.presentToast(err);
// this.flag=true;
});
}
In the html I have the next:
<ion-content padding>
<p>test</p>
<p>Picture Taken</p>
<img src={{base64Image[0]}}>
</ion-content padding>
Funny thing, a week ago, the first time I created de .ipa file the image showed up in the view after taking the picture, but two days later I just get a blank square on the view and cant figure out a way of fixing it. Also I have proved that the picture is taken since then upload it to Firebase Storage and get the download link.
upload() {
let localuseruid = this.auth.userSession;
let storageRef = firebase.storage().ref();
let localtime = new Date().toLocaleString().replace('/', '-').replace('/', '-').replace(',', '').replace('AM', '').replace('PM', '');
//Uploading img1
const filename = 'IMG1'+localtime ;
const imageRef = storageRef.child(`${this.globalVar.userStorageCurrentInstall}/${localuseruid.uid}/${filename}.jpg`);
imageRef.putString(this.base64Image[0], firebase.storage.StringFormat.DATA_URL)
.then((savedPicture) => {
this.imgsLink.push(savedPicture.downloadURL);
let data = this.datPro.update(this.globalVar.usersPath + localuseruid.uid + '/' + this.globalVar.userStorageCurrentInstall + '/' + localtime, {
linkstage1: this.imgsLink[0],
});
})
.catch((err) => {
this.presentToast(err);
});
}
Thank you for the help.