You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/11/12 16:00:37 UTC
[3/3] android commit: not getting the path correctly if the URI
contains a file://
not getting the path correctly if the URI contains a file://
Previous to 2.2 this function was crashing if the URI wasn't different
than a 'content://' but still if it is a 'file://' it fails getting the
correct path.
This happens for example picking a picture from dropbox instead of
local gallery.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/1d262398
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/1d262398
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/1d262398
Branch: refs/heads/master
Commit: 1d26239809fa6c32cc1ed293a911110f551d8985
Parents: 81f283e
Author: Alvaro <al...@livlivsolutions.com>
Authored: Fri Nov 9 09:28:26 2012 +0200
Committer: Alvaro <al...@livlivsolutions.com>
Committed: Fri Nov 9 09:28:26 2012 +0200
----------------------------------------------------------------------
framework/src/org/apache/cordova/FileUtils.java | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/1d262398/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index 973b820..46f2e9c 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -1069,16 +1069,18 @@ public class FileUtils extends CordovaPlugin {
*/
@SuppressWarnings("deprecation")
protected static String getRealPathFromURI(Uri contentUri, CordovaInterface cordova) {
- String uri = contentUri.toString();
- if (uri.startsWith("content:")) {
+ final String scheme = contentUri.getScheme();
+
+ if (scheme.compareTo("content") == 0) {
String[] proj = { _DATA };
Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(_DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
+ } else if (scheme.compareTo("file") == 0) {
+ return contentUri.getPath();
} else {
- return uri;
+ return contentUri.toString();
}
-
}
}