[ https://issues.apache.org/jira/browse/CB-5946?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joe Bowser updated CB-5946: --------------------------- Labels: Android (was: ) Component/s: (was: Android) > 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: Plugin File Transfer > Affects Versions: 3.3.0 > Reporter: Joachim Piketz > Labels: Android > > 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.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org