Permalink
Browse files

CB-539: FileTransfer.download fails when target starts with 'file://'

  • Loading branch information...
1 parent 180696b commit 7b75e2f1b0f51f70f22c765719a3c9523b78c7af @macdonst macdonst committed Apr 18, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 framework/src/org/apache/cordova/FileTransfer.java
@@ -410,7 +410,7 @@ public FileUploadResult upload(String file, String server, final String fileKey,
*/
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 @@ else if (path.startsWith("file://")) {
}
}
+ /**
+ * 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);
+ }
+ }
}

0 comments on commit 7b75e2f

Please sign in to comment.