cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joachim Piketz (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CB-5946) Automatic mime type in Filetransfer plugin
Date Thu, 30 Jan 2014 13:00:11 GMT

     [ https://issues.apache.org/jira/browse/CB-5946?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Joachim Piketz updated CB-5946:
-------------------------------

    Description: 
Feature request: automatically detect mime type in filetransfer plugin.
The following works for me in Android:
{code}
        String mime = null;
        try 
        {
        	mime = this.cordova.getActivity().getContentResolver().getType(sourceUri);
        	if (mime == null)
        	{
        	    MimeTypeMap mimemap = MimeTypeMap.getSingleton();
        	    String uri = sourceUri.toString();
        	    int index = uri.lastIndexOf('.');
        	    if (index != -1)
	        	    mime = mimemap.getMimeTypeFromExtension(uri.substring(index+1).toLowerCase());
        	}
        }
        catch (Exception e)
        {
        	Log.e(LOG_TAG, e.getMessage(), e);        	
        }
        
        if (mime == null)
        	mime = "application/octet-stream";
        
        final String mimeType = mime; 
        		
        Log.d(LOG_TAG, "mimeType: " + mimeType);
{code}

  was:
Feature request: automatically detect mime type in filetransfer plugin.
The following works for me in Android:
{code}
        String mime = "application/octet-stream";
        try 
        {
        	mime = cordova.getActivity().getContentResolver().getType(sourceUri);
        }
        catch (Exception e)
        {
          Log.e(LOG_TAG, e.getMessage(), e);        	
        }
        final String mimeType = mime; 
        Log.d(LOG_TAG, "mimeType: " + mimeType);
{code}


> Automatic mime type in Filetransfer plugin
> ------------------------------------------
>
>                 Key: CB-5946
>                 URL: https://issues.apache.org/jira/browse/CB-5946
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: Android, Plugin File Transfer
>    Affects Versions: 3.3.0
>            Reporter: Joachim Piketz
>
> Feature request: automatically detect mime type in filetransfer plugin.
> The following works for me in Android:
> {code}
>         String mime = null;
>         try 
>         {
>         	mime = this.cordova.getActivity().getContentResolver().getType(sourceUri);
>         	if (mime == null)
>         	{
>         	    MimeTypeMap mimemap = MimeTypeMap.getSingleton();
>         	    String uri = sourceUri.toString();
>         	    int index = uri.lastIndexOf('.');
>         	    if (index != -1)
> 	        	    mime = mimemap.getMimeTypeFromExtension(uri.substring(index+1).toLowerCase());
>         	}
>         }
>         catch (Exception e)
>         {
>         	Log.e(LOG_TAG, e.getMessage(), e);        	
>         }
>         
>         if (mime == null)
>         	mime = "application/octet-stream";
>         
>         final String mimeType = mime; 
>         		
>         Log.d(LOG_TAG, "mimeType: " + mimeType);
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message