简体   繁体   English

不允许加载本地资源:Ionic3(ios)

[英]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 不允许加载本地资源: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. 在Android设备它工作正常,但在ios我无法避免这个问题我相信这是由于一些安全问题,这将是一个很好的帮助我。

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 iOS相机插件返回包含新捕获协议的源代码,但在HTML中使用它来设置img或video等元素的来源时,需要删除协议

You can read more about it here: Ionic 3: File_URI Not allowed to load local resource IOS 您可以在此处阅读更多相关信息: Ionic 3:File_URI不允许加载本地资源IOS

I hope that helps! 我希望有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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