Cordova Camera Plugin, from Gallery [Android] Get full image path

I am trying to get images from a gallery with cordova camera plugin, this is how I did it:

navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
destinationType: Camera.DestinationType.FILE_URI,
mediaType: Camera.MediaType.ALLMEDIA,
encodingType: Camera.EncodingType.JPEG
});

But in my’onSuccess’ function, I get the image URI in the following format:

"content://com.android.providers.media.documents/document/image%3A1509"

I want the URI to have the full path of the image , Like I get it when I use the camera:

"file:///storage/emulated/0/Pictures/IMG_20150710_124222.jpg"

Reading the official documentation I have seen that the only thing I should do is set the attribute’DestinationType’ to’FILE_URI’, which has been set, as shown above.

What am I doing wrong?

I found a plug-in that converts the URI in the format of’content: // …’to complete It’s not a perfect solution, but it’s a plug-in that worked for me. The plug-in is cordova-plugin-filepath. I use it in the onSuccess callback of the getCamera function:

function onSuccess(imageURI) {
window.FilePath.resolveNativePath(imageURI, function(result) {
// onSuccess code
imageURI ='file://' + result;
.. .
}, function (error) {
// onError code here
}
}

I am trying to get images from a gallery with cordova camera plugin, this is how I did it:

navigator.camera.getPicture (onSuccess, onFail, {
quality: 50,
sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
destinationType: Camera.DestinationType.FILE_URI,
mediaType: Camera.MediaType.ALLMEDIA,
encodingType: Camera.EncodingType.JPEG
});

But in my’onSuccess’ function, I got the image URI in the following format:

"content://com.android.providers.media.documents/document/image%3A1509"

I want the URI to have the full path of the image, just Like I got it when I used the camera:

"file:///storage/emulated/0/Pictures/IMG_20150710_124222.jpg"

Read I have seen in the official documentation that the only thing I should do is set the attribute’DestinationType’ to’FILE_URI’, which has already been set, as shown above.

What am I doing wrong?

I found a plug-in that converts the URI in the format of’content: // …’into a complete file path. It is not a perfect solution, but It is a plug-in that works for me. The plug-in is cordova-plugin-filepath. I use it in the onSuccess callback of the getCamera function:

function onSuccess(imageURI) {
window.FilePath.resolveNativePath(imageURI, function(result) {
// onSuccess code
imageURI ='file://' + result;
.. .
}, function (error) {
// onError code here
}
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3770 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.