cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Haley (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-7768) captureImage (onActivityResult) in media-capture Plugin Throws FileNotFoundException
Date Mon, 10 Nov 2014 18:26:34 GMT

    [ https://issues.apache.org/jira/browse/CB-7768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14205115#comment-14205115
] 

Chris Haley commented on CB-7768:
---------------------------------

Thanks, David. I found it right after I asked, doh!

Interestingly, though, when I comment out the {{openOutputStream}} method and replace it with
your code, I seem to get the same error. It's a {{java.io.FileNotFoundException: No such file
or directory}}. From Capture.java, how do you output the value of {{uri}} to view it in Eclipse's
console? Could there be an error in getting {{uri}} so it's not even making it to the code
I copied from you?

> 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
>
> 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


Mime
View raw message