From 4fe73cf6ad5ebeb85f0c5868c12af25b66b6b2a0 Mon Sep 17 00:00:00 2001 From: Simon MacDonald Date: Mon, 12 Nov 2012 10:00:32 -0500 Subject: [PATCH] CB-1835: Camera.getPicture gives error when get a picture from photo library with spaces in its name on Android --- framework/src/org/apache/cordova/FileUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java index 46f2e9c3..c2f90b64 100755 --- a/framework/src/org/apache/cordova/FileUtils.java +++ b/framework/src/org/apache/cordova/FileUtils.java @@ -984,8 +984,11 @@ public class FileUtils extends CordovaPlugin { * @return a mime type */ public static String getMimeType(String filename) { + // Stupid bug in getFileExtensionFromUrl when the file name has a space + // So we need to replace the space with a url encoded %20 + String url = filename.replace(" ", "%20"); MimeTypeMap map = MimeTypeMap.getSingleton(); - return map.getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(filename)); + return map.getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(url)); } /**