Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between FILE_URI and NATIVE_URI in cordova plugin camera

What is the different between FILE_URI and NATIVE_URI in cordova plugin camera?

like image 751
Riyad Khalifeh Avatar asked Jun 18 '15 16:06

Riyad Khalifeh


1 Answers

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

like image 161
Kim T Avatar answered Oct 26 '22 10:10

Kim T