Ionic 3:File_URI不允许加载本地资源IOS [英] Ionic 3: File_URI Not allowed to load local resource IOS

查看:2056
本文介绍了Ionic 3:File_URI不允许加载本地资源IOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用相机拍摄图像并进行预览。它需要发送到服务器,所以我使用目标类型'FILE_URI'。当我在Android上运行它时,它工作,但我在ios 10.3.1上运行它时出现此错误

Im using the camera to take an image and preview it. It needs to be sent to a server so Im using the destination type of 'FILE_URI'. It works when I run it on android, but Im getting this error running it on ios 10.3.1

不允许加载本地资源:文件:///var/mobile/Containers/Data/Application/2CE518F3-4F4E-42A9-94E1-DC06D01250C7/tmp/cdv_photo_001.jpg

Not allowed to load local resource : file:///var/mobile/Containers/Data/Application/2CE518F3-4F4E-42A9-94E1-DC06D01250C7/tmp/cdv_photo_001.jpg

我没有使用-lc标记运行它。编码类型是JPEG

I am not running it with the -lc tag. The encoding type is JPEG

推荐答案

我遇到了同样的问题,我意识到在iOS相机插件中返回带有新协议的协议来源但是当你在HTML中使用它来设置像img或视频这样的元素的来源时你需要删除协议...所以我做了:

I was facing same problem and I realized that in 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... So I did :

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

如果你想将捕获移动到其他地方恢复协议或预先复制或者其他什么

If you want to move capture to somewhere else restore protocol or make a copy beforehand or whatever

希望它有帮助

这篇关于Ionic 3:File_URI不允许加载本地资源IOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆