cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (CB-10093) No file path is returned when selecting picture from third party apps
Date Thu, 03 Dec 2015 06:04:11 GMT


ASF GitHub Bot commented on CB-10093:

GitHub user sencenan opened a pull request:

    [CB-10093][CB-9960][android] fix error resolving content uri to file url

    Different app returns different uri. This is causing getRealPath() to return empty path.
    - Gallery: content://media/external/images/media/117209
    - Google Photo: embeds a external image link inside another uri
    - Dropbox: old school file url
    Not fixed:
    - Google Drive: document uri, but has no document id, or the id cannot be used to query
content resolver
    I have tested with: Gallery, Dropbox, Google Photo, and various file manager apps. However,
this fix as is still does not address the problem with Google Drive.
    It seems to me that trying to get real file path from content uri seems to be a fundamentally
flawed solution. It breaks the google sandbox between apps and this is going to get worse
when more apps start to return the URL in "non-standard" formats.
    Use getContentResolver().openInputStream() and read the file directly could be a way forward,
given that we are copying the image file already.
    For reference, I am using this following hack for my own branch to address problem with
Google Drive:
    private String ouputModifiedBitmap(Bitmap bitmap, Uri uri) throws IOException {
            // Some content: URIs do not map to file paths (e.g. picasa).
            String realPath = FileHelper.getRealPath(uri, this.cordova);
            //START OF HACK
            if (realPath.length() == 0) {
                String copiedFilePath = getTempDirectoryPath() + "/"
                        + System.currentTimeMillis() + ".copied."
                        + (this.encodingType == JPEG ? "jpg" : "png");
                InputStream fin = this.cordova.getActivity().getContentResolver().openInputStream(uri);
                OutputStream fout = new FileOutputStream(copiedFilePath);
                byte[] buf = new byte[1024 * 4];
                int len;
                while ((len = > 0) {
                    fout.write(buf, 0, len);
                realPath = copiedFilePath;
            //END OF HACK
            // rest of ouputModifiedBitmap method

You can merge this pull request into a Git repository by running:

    $ git pull master

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #143
commit c09a8cf09b371c6071256444b81b18c10b3b70af
Author: <>
Date:   2015-11-30T20:18:03Z

    m: fix the crash when the uri passed into outputModifiedBitmap() is not a document URI

commit 05cdb0133f53fff109298ac2fb10a89026bb6462
Author: sencenan <>
Date:   2015-12-01T20:27:10Z

    m: response to code reivew on pull request 141

commit 83978ea3736168520eae2935ee0318d6fb9bc7c3
Author: <>
Date:   2015-12-03T05:49:47Z

    [CB-10093][CB-9960][android] fix error resolving content uri to file url


> No file path is returned when selecting picture from third party apps
> ---------------------------------------------------------------------
>                 Key: CB-10093
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Camera
>         Environment: Android 6.0, Android 5.1.1, Camera plugin 2.0.0, Cordova 5.4.0
>            Reporter: Ying Wei Loke
>              Labels: android
> 1) Camera.getPicture with 
> - source type: PHOTOLIBRARY
> - destination type: FILE_URI
> 2) On the photo library, open other apps from menu (e.g. gallery/file manager/One Drive,
> 3) Select any picture.
> Actual result:
> No file path for the picture selected is returned to the camera plugin.
> Note: Was working previously on plugin version 1.2.0.
> Logs with logcat:
> D/Documents(29453): onActivityResult() code=-1
> V/WindowManager(  543): rotationForOrientationLw(orient=1, last=0); user=0 
> D/CordovaInterfaceImpl(15585): Sending activity result to plugin
> D/CameraLauncher(15585): File locaton is: 
> I/Timeline(15585): Timeline: Activity_idle id: android.os.BinderProxy@16b7c72d time:10419445
> W/System.err(15585): /storage/emulated/0/Android/data/com.likemindnetworks.apps.teamDental/cache:
open failed: EISDIR (Is a directory)
> W/System.err(15585): 	at
> W/System.err(15585): 	at<init>(
> W/System.err(15585): 	at<init>(
> W/System.err(15585): 	at<init>(
> W/System.err(15585): 	at
> W/System.err(15585): 	at
> W/System.err(15585): 	at$000(
> W/System.err(15585): 	at$
> W/System.err(15585): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(
> W/System.err(15585): 	at java.util.concurrent.ThreadPoolExecutor$
> W/System.err(15585): 	at
> W/System.err(15585): Caused by: android.system.ErrnoException: open failed: EISDIR (Is
a directory)
> W/System.err(15585): 	at Method)
> W/System.err(15585): 	at
> W/System.err(15585): 	at
> W/System.err(15585): 	... 10 more

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message