2016-04-26 61 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'">

使用現場重裝時,這是行不通的。