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 B69F610514 for ; Thu, 30 Jan 2014 13:00:13 +0000 (UTC) Received: (qmail 54226 invoked by uid 500); 30 Jan 2014 13:00:13 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 54144 invoked by uid 500); 30 Jan 2014 13:00:12 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 54106 invoked by uid 99); 30 Jan 2014 13:00:11 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jan 2014 13:00:11 +0000 Date: Thu, 30 Jan 2014 13:00:11 +0000 (UTC) From: "Joachim Piketz (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CB-5946) Automatic mime type in Filetransfer plugin 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-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)