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 2012/07/28 02:19:35 UTC

js commit: FileTransfer: Allow headers to be set in FileUploadOptions.

Updated Branches:
  refs/heads/master 18e390f48 -> 8c46a970a


FileTransfer: Allow headers to be set in FileUploadOptions.


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/8c46a970
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/8c46a970
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/8c46a970

Branch: refs/heads/master
Commit: 8c46a970a0719d0f16a225b75421ecf6f12dcc02
Parents: 18e390f
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jul 12 16:33:55 2012 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jul 27 20:17:10 2012 -0400

----------------------------------------------------------------------
 lib/common/plugin/FileTransfer.js      |    4 +++-
 lib/common/plugin/FileUploadOptions.js |    7 +++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8c46a970/lib/common/plugin/FileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/FileTransfer.js b/lib/common/plugin/FileTransfer.js
index 3ec6721..38a44b6 100644
--- a/lib/common/plugin/FileTransfer.js
+++ b/lib/common/plugin/FileTransfer.js
@@ -26,10 +26,12 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
     var mimeType = null;
     var params = null;
     var chunkedMode = true;
+    var headers = null;
     if (options) {
         fileKey = options.fileKey;
         fileName = options.fileName;
         mimeType = options.mimeType;
+        headers = options.headers;
         if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
             chunkedMode = options.chunkedMode;
         }
@@ -46,7 +48,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
         errorCallback(error);
     };
 
-    exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
+    exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers]);
 };
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8c46a970/lib/common/plugin/FileUploadOptions.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/FileUploadOptions.js b/lib/common/plugin/FileUploadOptions.js
index 78fa9f9..23b198c 100644
--- a/lib/common/plugin/FileUploadOptions.js
+++ b/lib/common/plugin/FileUploadOptions.js
@@ -5,12 +5,15 @@
  * @param fileName {String}  Filename to be used by the server. Defaults to image.jpg.
  * @param mimeType {String}  Mimetype of the uploaded file. Defaults to image/jpeg.
  * @param params {Object}    Object with key: value params to send to the server.
+ * @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) {
+var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers) {
     this.fileKey = fileKey || null;
     this.fileName = fileName || null;
     this.mimeType = mimeType || null;
     this.params = params || null;
+    this.headers = headers || null;
 };
 
-module.exports = FileUploadOptions;
\ No newline at end of file
+module.exports = FileUploadOptions;