在ngSrc中使用相机插件中的FILE_URI [英] Use FILE_URI from camera plugin in ngSrc

查看:136
本文介绍了在ngSrc中使用相机插件中的FILE_URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ionic-native 库来访问带有以下选项的相机插件:

I use ionic-native library to access the camera plugin with the following options:

let options = {
quality:50,
destinationType:1,
sourceType:1,
allowEdit:false,
encodingType:1,
mediaType:0,
correctOrientation:true,
saveToPhotoAlbum:false,
cameraDirection:1
};

拍完照片后,我得到 FILE_URI file:/// storage / emulated / 0 / Android / data / com.company.testApp / cache / 1461661383435.png
但是当我在<$ c $的 ngSrc 属性中使用它时c> img tag,它只显示一个空块。
在使用chrome检查时,对图像的请求状态为(阻止:其他)

After taking the picture, I get the FILE_URI as file:///storage/emulated/0/Android/data/com.company.testApp/cache/1461661383435.png But when I use it in the ngSrc property of the img tag, It just displays an empty block. While inspecting with chrome, the request for the image has the status of (blocked:other)

此外,我不想使用 DATA_URL ,因为它会降低性能。

Also I don't want to use DATA_URL, since it degrades the performance.

推荐答案

这篇文章

在Android 4.4 +上允许访问本地文件资源是显而易见的。

It is EXPLICITLY needed to allow access to local file resource at Android 4.4+.

将以下行添加到 config.xml

< allow-navigation href =*/>
< allow-navigation href =file:// * / */>

并设置 Content-Security-Policy in index.html as

And also set the Content-Security-Policy in index.html as

< meta http-equiv =Content-Security-Policycontent =default-src *; style-src'self''unsafe-inline'; script-src'self''unsafe-inline ''unsafe-eval'>

使用实时重新加载时,这不起作用。

这篇关于在ngSrc中使用相机插件中的FILE_URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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