Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A782B1809B for ; Wed, 14 Oct 2015 18:28:15 +0000 (UTC) Received: (qmail 43939 invoked by uid 500); 14 Oct 2015 18:28:06 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 43900 invoked by uid 500); 14 Oct 2015 18:28:06 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 43750 invoked by uid 99); 14 Oct 2015 18:28:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Oct 2015 18:28:05 +0000 Date: Wed, 14 Oct 2015 18:28:05 +0000 (UTC) From: "David Perry (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-7768) captureImage (onActivityResult) in media-capture Plugin Throws FileNotFoundException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-7768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14957467#comment-14957467 ] David Perry commented on CB-7768: --------------------------------- Thanks [~bowserj]. If it still is an issue, like I said, I'm fine with you fixing it and taking credit. If you still prefer that I create a pull request, I can do that if you can confirm that my fix won't blow up Android phones all over the world. :) > captureImage (onActivityResult) in media-capture Plugin Throws FileNotFoundException > ------------------------------------------------------------------------------------ > > Key: CB-7768 > URL: https://issues.apache.org/jira/browse/CB-7768 > Project: Apache Cordova > Issue Type: Bug > Components: Android > Affects Versions: 3.5.0 > Environment: Samsung Galaxy S5, Android 4.4.4. > Reporter: David Perry > Attachments: Capture.zip > > > It appears that the issue is that the uri returned by that.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values) is not properly resolved by OutputStream os = that.cordova.getActivity().getContentResolver().openOutputStream(uri). > What worked for me was instead of calling openOutputStream, do the following: > String dfname = getRealPathFromURI(uri); > File df = new File(dfname); > File dfolder = df.getParentFile(); > if(!dfolder.exists()) dfolder.mkdirs(); > if(!df.exists()) df.createNewFile(); > FileOutputStream os = new FileOutputStream(df); > private String getRealPathFromURI(Uri contentURI) { > Cursor cursor = this.cordova.getActivity().getContentResolver().query(contentURI, null, null, null, null); > if (cursor == null) { // Source is Dropbox or other similar local file path > return contentURI.getPath(); > } else { > cursor.moveToFirst(); > int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); > return cursor.getString(idx); > } > } -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org For additional commands, e-mail: issues-help@cordova.apache.org