2016-04-26 118 views
1

相机插件我用ionic-native库下列选项访问摄像头插件:使用FILE_URI从ngSrc

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 但是当我用它在img标记的ngSrc属性中,它只显示一个空白块。 使用铬检查时,图像请求的状态为(blocked:other)

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

回答

0

此回答在this post被建议。

明显需要允许在Android 4.4+以上访问本地文件资源。

添加以下行至​​3210:

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

,还可以设置在index.htmlContent-Security-Policy作为

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

使用现场重装时,这是行不通的。