Search code examples
androidcordovacordova-plugins

Cordova Camera Plugin: Not allowed to load local resource (content://)


I have a Cordova app. In some part of the app, I let the user choose a photo from the gallery or take one with the camera. For this purpose, I’m using cordova-plugin-camera.

The problem is when the user takes a photo with the camera, the preview is fine, but when they choose it from the gallery, the preview of the photo is broken.

This is the error I get for the broken preview: Not allowed to load local resource: content://com.android.providers.media.documents/document/image%3A6717.

I'm using navigator.camera.getPicture function with destinationType: Camera.DestinationType.NATIVE_URL.

This happens on Android devices. Do you have any idea what causes this?

By the way, I have already added <access origin="content:///*" /> to the config.xml file, but it's not working.


Solution

  • The solution is to convert content URI to the native path using cordova-plugin-filepath: https://stackoverflow.com/a/33127554/3752067