MX Starter
MX Starter

Reputation: 85

camera.getPicture() returns an unexpected FILE_URI on Android

using the plugin i'm trying to take photo in my app trough the camera.getPicture() method. Here is the code:

navigator.camera.getPicture(onSuccess, onFail, {
    quality: 50,
    destinationType: Camera.DestinationType.FILE_URI
});

According to the Cordova docs (https://cordova.apache.org/docs/en/10.x/reference/cordova-plugin-camera/index.html), the success callback should receive something like

content://media/external/images/media/2 for the file uri, however i only receive this:

file///data/user/0/com.tld.appname/cache/1642011143203.jpg.

Trying to use this value as an image src in the WebView does nothing and i'm unable to find the file within the phone filesystem (there is no file///data/user/0/com.tld.appname directory available). The phone is Samsung Galaxy S6 Edge, Android 7.0.

Other software versions:

What is wrong here?

When i use DATA_URL as destination, it is working fine, however the Cordova docs states this could result in memory problems.

Upvotes: 1

Views: 1659

Answers (1)

Eric
Eric

Reputation: 10626

Add this to your config so the WebView can load local files from file://

 <preference name="AndroidInsecureFileModeEnabled" value="true" />

Upvotes: 1

Related Questions