You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/07/18 23:05:45 UTC
[4/10] js commit: added FileTransfer
added FileTransfer
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/f4a423d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/f4a423d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/f4a423d2
Branch: refs/heads/master
Commit: f4a423d23d0c19427c646a9c12f85cddfcd6176e
Parents: 0993a57
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jul 17 16:35:29 2012 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jul 17 16:35:29 2012 -0700
----------------------------------------------------------------------
lib/wp7/exec.js | 11 ++++++-----
lib/wp7/plugin/wp7/FileTransfer.js | 15 +++++++++++++--
2 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f4a423d2/lib/wp7/exec.js
----------------------------------------------------------------------
diff --git a/lib/wp7/exec.js b/lib/wp7/exec.js
index 2254355..74421e9 100644
--- a/lib/wp7/exec.js
+++ b/lib/wp7/exec.js
@@ -24,11 +24,12 @@ var NamedArgs = {
moveTo:["fullPath","parent", "newName"],
requestFileSystem:["type","size"],
resolveLocalFileSystemURI:["uri"]
- },
- FileTransfer:{
- upload:["filePath", "server", "fileKey", "fileName", "mimeType", "params", "debug", "chunkedMode"],
- download:["url","filePath"]
- },
+ }
+ // ,
+ // FileTransfer:{
+ // upload:["filePath", "server", "fileKey", "fileName", "mimeType", "params", "debug", "chunkedMode"],
+ // download:["url","filePath"]
+ // },
};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f4a423d2/lib/wp7/plugin/wp7/FileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/FileTransfer.js b/lib/wp7/plugin/wp7/FileTransfer.js
index 4840b4d..c4baef7 100644
--- a/lib/wp7/plugin/wp7/FileTransfer.js
+++ b/lib/wp7/plugin/wp7/FileTransfer.js
@@ -1,6 +1,9 @@
var exec = require('cordova/exec'),
FileTransferError = require('cordova/plugin/FileTransferError');
+// Note that the only difference between this and the default implementation is the
+// object literal passed to exec() in upload - jm
+
/**
* FileTransfer uploads a file to a remote server.
* @constructor
@@ -51,8 +54,14 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
errorCallback(error);
};
-
- exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
+ exec(successCallback, fail, 'FileTransfer', 'upload', [{"filePath":filePath,
+ "server":server,
+ "fileKey":fileKey,
+ "fileName":fileName,
+ "mimeType":mimeType,
+ "params":params,
+ "trustAllHosts":trustAllHosts,
+ "chunkedMode":chunkedMode}]);
};
/**
@@ -62,6 +71,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
* @param successCallback (Function} Callback to be invoked when upload has completed
* @param errorCallback {Function} Callback to be invoked upon error
*/
+
FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
// sanity parameter checking
if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum.");
@@ -88,4 +98,5 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
};
+
module.exports = FileTransfer;