You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/04/20 01:24:58 UTC
[5/13] android commit: CB-539: FileTransfer.download fails when
target starts with 'file://'
CB-539: FileTransfer.download fails when target starts with 'file://'
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/7b75e2f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/7b75e2f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/7b75e2f1
Branch: refs/heads/CordovaWebView
Commit: 7b75e2f1b0f51f70f22c765719a3c9523b78c7af
Parents: 180696b
Author: macdonst <si...@gmail.com>
Authored: Wed Apr 18 13:56:29 2012 -0400
Committer: macdonst <si...@gmail.com>
Committed: Wed Apr 18 13:56:29 2012 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/FileTransfer.java | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/7b75e2f1/framework/src/org/apache/cordova/FileTransfer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileTransfer.java b/framework/src/org/apache/cordova/FileTransfer.java
index 315344b..a631a05 100644
--- a/framework/src/org/apache/cordova/FileTransfer.java
+++ b/framework/src/org/apache/cordova/FileTransfer.java
@@ -410,7 +410,7 @@ public class FileTransfer extends Plugin {
*/
public JSONObject download(String source, String target) throws IOException {
try {
- File file = new File(target);
+ File file = getFileFromPath(target);
// create needed directories
file.getParentFile().mkdirs();
@@ -488,4 +488,17 @@ public class FileTransfer extends Plugin {
}
}
+ /**
+ * Get a File object from the passed in path
+ *
+ * @param path
+ * @return
+ */
+ private File getFileFromPath(String path) {
+ if (path.startsWith("file://")) {
+ return new File(path.substring(7));
+ } else {
+ return new File(path);
+ }
+ }
}