You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2015/11/11 07:37:26 UTC
cordova-plugin-file-transfer git commit: CB-51 API: FileTransfer -
Support PUT Method
Repository: cordova-plugin-file-transfer
Updated Branches:
refs/heads/master 587e05122 -> 5857384b9
CB-51 API: FileTransfer - Support PUT Method
Adds a test for upload via PUT method
Adds support for Windows platform
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/5857384b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/5857384b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/5857384b
Branch: refs/heads/master
Commit: 5857384b943ced5ea7b949882b103f4638d25d27
Parents: 587e051
Author: daserge <v-...@microsoft.com>
Authored: Wed Nov 11 09:28:21 2015 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Wed Nov 11 09:28:21 2015 +0300
----------------------------------------------------------------------
src/windows/FileTransferProxy.js | 2 ++
tests/tests.js | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/5857384b/src/windows/FileTransferProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/FileTransferProxy.js b/src/windows/FileTransferProxy.js
index 0c4e8b0..d3e8520 100644
--- a/src/windows/FileTransferProxy.js
+++ b/src/windows/FileTransferProxy.js
@@ -78,6 +78,7 @@ exec(win, fail, 'FileTransfer', 'upload',
// var chunkedMode = options[7]; // todo
var headers = options[8] || {};
var uploadId = options[9];
+ var httpMethod = options[10];
if (!filePath || (typeof filePath !== 'string')) {
errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR,null,server));
@@ -122,6 +123,7 @@ exec(win, fail, 'FileTransfer', 'upload',
// setting request headers for uploader
var uploader = new Windows.Networking.BackgroundTransfer.BackgroundUploader();
+ uploader.method = httpMethod;
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
uploader.setRequestHeader(header, headers[header]);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/5857384b/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 4e3d08a..083435f 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -895,6 +895,33 @@ exports.defineAutoTests = function () {
transfer.upload(localPath, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptions);
}, unsupported, 'File', '_getLocalFilesystemPath', [internalFilePath]);
}, UPLOAD_TIMEOUT);
+
+ it("filetransfer.spec.31 should be able to upload a file using PUT method", function (done) {
+
+ var fileURL = SERVER + '/upload';
+
+ var uploadWin = function (uploadResult) {
+
+ verifyUpload(uploadResult);
+
+ if (cordova.platformId === 'ios') {
+ expect(uploadResult.headers).toBeDefined('Expected headers to be defined.');
+ expect(uploadResult.headers['Content-Type']).toBeDefined('Expected content-type header to be defined.');
+ }
+
+ done();
+ };
+
+ var uploadOptionsPut = new FileUploadOptions();
+ uploadOptionsPut.fileKey = "file";
+ uploadOptionsPut.fileName = fileName;
+ uploadOptionsPut.mimeType = "text/plain";
+ uploadOptionsPut.params = uploadParams;
+ uploadOptionsPut.httpMethod = "PUT";
+
+ // NOTE: removing uploadOptions cause Android to timeout
+ transfer.upload(localFilePath, fileURL, uploadWin, unexpectedCallbacks.httpFail, uploadOptionsPut);
+ }, UPLOAD_TIMEOUT);
});
});
});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org