简体   繁体   中英

Not allowed to load local resource: Ionic3(ios)

I am getting this issue

Not allowed to load local resource: file:///var/mobile/Containers/Data/Application/AB6EABD9-CAAF-4AE5-91F9-D8042B34EA87/tmp/cdv_photo_002.jpg

My code looks like

let cameraOptions = {
      quality: 50,
      destinationType: this.camera.DestinationType.FILE_URI,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
    }

this.camera.getPicture(cameraOptions).then((imageData) => {
   this.myImage = imageData;
})

In android device it works fine but in ios i am not able to avoid this issue i am sure it is due to some security issue it would be great some one help me.

I think something like this might work for you:

if (isIos()) {
  itemSrc = itemSrc.replace(/^file:\/\//, '');
}

Based off of another thread I saw:

iOS camera plugin returns source with protocol for new captures but when using it in your HTML to set the source of an element like img or video you need to remove protocol

You can read more about it here: Ionic 3: File_URI Not allowed to load local resource IOS

I hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM