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

Christian Kuetbach commented on CB-2501:
----------------------------------------

OK, I think I mixed two problems:

1. I used cordova 2.2 in my project. There was a bug, that a file with a 
Upper-Case extension did not work (See the android-bug I linked).
2. MimeTypeMap only works for file://, because a content:// has no 
file-extension. One should use the content-resolver for any mimetype (and size) 
mappings.

As I started the create a patch for problem 1. I found out, it was already 
fixed.

The suggestion, that the mimetype can only be resolved with the 
content-resolver is fixed in line 1013, but only for one call.

        String contentType = null;
        if (filename.startsWith("content:")) {
            Uri fileUri = Uri.parse(filename);
            contentType = 
this.cordova.getActivity().getContentResolver().getType(fileUri);
        }
        else {
            contentType = getMimeType(filename);
        }

But I think, it would be better, to only use the contentresolver.

But to fix this, the complete mechanism with createFileObject() have to be 
replaced by the content-resolver. because, from a content:// you may not create 
a File-object.

I think there should be a review of this class.
                
> FileUtils.getMimeType(String file) does not work for content:// URIs
> --------------------------------------------------------------------
>
>                 Key: CB-2501
>                 URL: https://issues.apache.org/jira/browse/CB-2501
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.2.0
>            Reporter: Christian Kuetbach
>            Assignee: Max Woghiren
>            Priority: Minor
>             Fix For: 2.4.0
>
>
> There is a bug in Android: 
> http://code.google.com/p/android/issues/detail?id=8806
> Because of this the returned mime type will be wrong, if the file extension 
> is not lowercase.
> myImage.jpg -> image/jpg
> myImage.JPG -> null
> I will provide a patch, which simply converts the filepath to lower case, but 
> think there is a better solution than using the MimeTypeMap. The Class 
> ContentResolver has a method getType() 
> http://developer.android.com/reference/android/content/ContentResolver.html#getType(android.net.Uri)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to