You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/03/27 19:29:53 UTC
js commit: [CB-51] Added httpMethod for file transfer options (allows
PUT or POST, defaults to POST)
Updated Branches:
refs/heads/master 02968603f -> f76d02f22
[CB-51] Added httpMethod for file transfer options (allows PUT or POST, defaults to POST)
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/f76d02f2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/f76d02f2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/f76d02f2
Branch: refs/heads/master
Commit: f76d02f22540c306eeb277d6ea98c1fca91c4dd7
Parents: 0296860
Author: Jasonm23 <ja...@gmail.com>
Authored: Fri Mar 22 14:11:22 2013 +1100
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Mar 27 14:14:56 2013 -0400
----------------------------------------------------------------------
lib/common/plugin/FileTransfer.js | 10 ++++++++--
lib/common/plugin/FileUploadOptions.js | 3 ++-
2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f76d02f2/lib/common/plugin/FileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/FileTransfer.js b/lib/common/plugin/FileTransfer.js
index 8c75db7..c909092 100644
--- a/lib/common/plugin/FileTransfer.js
+++ b/lib/common/plugin/FileTransfer.js
@@ -94,7 +94,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
var params = null;
var chunkedMode = true;
var headers = null;
-
+ var httpMethod = null;
var basicAuthHeader = getBasicAuthHeader(server);
if (basicAuthHeader) {
options = options || {};
@@ -107,6 +107,12 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
fileName = options.fileName;
mimeType = options.mimeType;
headers = options.headers;
+ httpMethod = options.httpMethod || "POST";
+ if (httpMethod.toUpperCase() == "PUT"){
+ httpMethod = "PUT";
+ } else {
+ httpMethod = "POST";
+ }
if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
chunkedMode = options.chunkedMode;
}
@@ -133,7 +139,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
successCallback && successCallback(result);
}
};
- exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id]);
+ exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
};
/**
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f76d02f2/lib/common/plugin/FileUploadOptions.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/FileUploadOptions.js b/lib/common/plugin/FileUploadOptions.js
index b004cf1..b2977de 100644
--- a/lib/common/plugin/FileUploadOptions.js
+++ b/lib/common/plugin/FileUploadOptions.js
@@ -29,12 +29,13 @@
* @param headers {Object} Keys are header names, values are header values. Multiple
* headers of the same name are not supported.
*/
-var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers) {
+var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) {
this.fileKey = fileKey || null;
this.fileName = fileName || null;
this.mimeType = mimeType || null;
this.params = params || null;
this.headers = headers || null;
+ this.httpMethod = httpMethod || null;
};
module.exports = FileUploadOptions;