What is the different between FILE_URI and NATIVE_URI in cordova plugin camera?
Asked
Active
Viewed 9,150 times
1 Answers
5
There are three options, and from what I understand they are different per platform:
Camera.DestinationType.FILE_URI
'file://' ios
'content://' android
Camera.DestinationType.NATIVE_URI
'assets-library://' ios
'content://' android
Camera.DestinationType.DATA_URL
'data:image/jpg;base64,'
If you want to convert them to other urls you can use the file plugin: https://github.com/apache/cordova-plugin-file
navigator.camera.getPicture(function (path) {
window.alert('getPicture.success: ' + JSON.stringify(path));
window.resolveLocalFileSystemURI(path, function (fileEntry) {
window.alert("success: " + JSON.stringify(fileEntry));
}, function (e) {
window.alert("error: " + JSON.stringify(e));
});
}, function (e) {
window.alert('getPicture.error: ' + JSON.stringify(e));
}, $scope.options);
Here is the documentation for the options: https://github.com/apache/cordova-plugin-camera/blob/master/www/CameraConstants.js
And also the link to the source code for this function: https://github.com/apache/cordova-plugin-file/blob/master/www/resolveLocalFileSystemURI.js

Kim T
- 5,770
- 1
- 52
- 79
-
Any idea how to choose between the gallery and the camera in the cordova-camera – gates Aug 12 '15 at 10:04
-
Yep! In your options object you can pass through: {sourceType: Camera.PictureSourceType.CAMERA} or {sourceType: Camera.PictureSourceType. PHOTOLIBRARY} – Kim T Aug 12 '15 at 13:06
-
I am sure you don't mean to say sourceType: Camera.PictureSourceType.CAMERA|| Camera.PictureSourceType.PHOTOLIBRARY :D, If you know what I mean! I mean to say it should give a pop up asking to select either one, now we need to create that pop up by ourselves and write duplicate code .. Argh! – gates Aug 12 '15 at 13:14
-
1Yeah, you need to create your own pop-up in html with two buttons, clicking the gallery you pass through Camera.PictureSourceType.PHOTOLIBRARY and for camera use Camera.PictureSourceType.CAMERA. I'm working on a plugin which allows you to select Gallery from the video camera view, but it's not finished! https://github.com/kmturley/cordova-plugin-media-custom – Kim T Aug 12 '15 at 13:40