Ionic Native Camera - Can't read from Native uri

#1

In Ionic 3 I used to use the normalizeURL method but that has been deprecated for Ionic 4. Any equivalents to resolve this issue? I tried the Angular DomSanitizer with no luck.

#2

Hi, @bandito
Try this :

takePicture(){
    const options: CameraOptions = {
      quality: 100,
      destinationType: this.camera.DestinationType.FILE_URI,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
    }

    this.camera.getPicture(options).then((imageData) => {
       this.photo = (<any>window).Ionic.WebView.convertFileSrc(imageData);
       console.log("fewf",this.photo)
          }, (err) => {
     // Handle error
    });
  }

I think this will help you

#3

This didn’t work for me :confused:

It isn’t bringing me any data (or doing anything really ,like nothing at all) when using this method

(<any>window).Ionic.WebView.convertFileSrc
#4

Hi, @bandito

Could you share your code here.

thanks

#5
    const options: CameraOptions = {
      quality: 100,
      sourceType: this.camera.PictureSourceType.SAVEDPHOTOALBUM,
      targetWidth: 250,
      targetHeight: 250,
      destinationType: this.camera.DestinationType.FILE_URI,
      mediaType: this.camera.MediaType.PICTURE,
      encodingType: this.camera.EncodingType.JPEG
    };
    this.camera.getPicture(options)
      .then((imageData: string) => {
        this.picture = (<any>window).Ionic.WebView.convertFileSrc(imageData);
      },
        error => handleError(error)
      );

@addwebsolution

#6

Hi

I just followed the instructions here and it solved the issue with FILE_URI.

But not when using NATIVE_URI :frowning:

#7

Anyone had any luck using Native Uri?

#8

From what I see when I try to copy a file using the Native Uri I can’t so what I did to keep it stored permanently using FILE_URI is to copy it from the /tmp/ folder to any other folder that iOS don’t delete.