Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D60718C32 for ; Tue, 1 Dec 2015 17:55:46 +0000 (UTC) Received: (qmail 40864 invoked by uid 500); 1 Dec 2015 17:55:45 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 40824 invoked by uid 500); 1 Dec 2015 17:55:45 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 40813 invoked by uid 99); 1 Dec 2015 17:55:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2015 17:55:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 60987E04BD; Tue, 1 Dec 2015 17:55:45 +0000 (UTC) From: riknoll To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-plugin-camera pull request: [CB-10093][android] fix failur... Content-Type: text/plain Message-Id: <20151201175545.60987E04BD@git1-us-west.apache.org> Date: Tue, 1 Dec 2015 17:55:45 +0000 (UTC) Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-plugin-camera/pull/141#discussion_r46312808 --- Diff: src/android/FileHelper.java --- @@ -79,30 +79,59 @@ public static String getRealPath(String uriString, CordovaInterface cordova) { @SuppressLint("NewApi") public static String getRealPathFromURI_API19(Context context, Uri uri) { String filePath = ""; + try { - String wholeID = DocumentsContract.getDocumentId(uri); + String id; + + if (DocumentsContract.isDocumentUri(context, uri)) { + String wholeID = DocumentsContract.getDocumentId(uri); - // Split at colon, use second item in the array - String id = wholeID.indexOf(":") > -1 ? wholeID.split(":")[1] : wholeID.indexOf(";") > -1 ? wholeID - .split(";")[1] : wholeID; + // Split at colon, use second item in the array + id = wholeID.indexOf(":") > -1 + ? wholeID.split(":")[1] + : wholeID.indexOf(";") > -1 + ? wholeID.split(";")[1] + : wholeID; + } else { + final String uriStr = uri.toString(); + + if ( + uriStr.startsWith( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString() + ) + ) { + id = uriStr.substring(uriStr.lastIndexOf("/") + 1); + } else { + throw new IllegalArgumentException( + "Cannot get real path from uri: " + uriStr + ); + } + } String[] column = { MediaStore.Images.Media.DATA }; // where id is equal to String sel = MediaStore.Images.Media._ID + "=?"; - Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, column, - sel, new String[] { id }, null); + Cursor cursor = context.getContentResolver().query( --- End diff -- Nitpick: Can we preserve the formatting of this? I don't think you changed the code here. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org For additional commands, e-mail: dev-help@cordova.apache.org