Reputation: 609
I want to format my URL from @ionic-native/camera
, however I cannot find where it's now since version changed.
Without it I get url like (looks good, but does not work):
Code:
getImage() {
const options: CameraOptions = {
quality: 100,
targetWidth: 600,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
};
this.camera.getPicture(options).then(
imageData => {
this.imageURI = imageData;
// this.sanitize.bypassSecurityTrustUrl(imageData);
alert(this.imageURI);
alert(imageData);
},
err => {
console.log(err);
alert(err);
}
);
}
Already tried bypassSecurityTrustUrl
, but no result. Unfortunately I cannot debug my code via Chrome or emulator for several reasons. Maybe normalizeUrl
can help me but it's not in the @ionic/angular package.
Upvotes: 1
Views: 1795
Reputation: 609
The solution was this code
After imports and before component insert
declare var window;
then
this.camera.getPicture(options).then(
imageData => {
this.imageURI = window.Ionic.WebView.convertFileSrc(imageData)
// this.sanitize.bypassSecurityTrustUrl(imageData);
alert(this.imageURI);
alert(imageData);
},
err => {
console.log(err);
alert(err);
}
);
worked like a charm!
Upvotes: 1