CB-10771: Fixing failure when empty string passed as a value for option parameter in upload function
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/58475486 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/58475486 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/58475486 Branch: refs/heads/1.5.x Commit: 584754869befd2d899f8e20270ba086ffe525625 Parents: 3d2d312 Author: Raghav Katyal <[email protected]> Authored: Thu Mar 24 17:17:15 2016 -0700 Committer: Raghav Katyal <[email protected]> Committed: Mon Mar 28 15:08:58 2016 -0700 ---------------------------------------------------------------------- README.md | 4 ++++ src/windows/FileTransferProxy.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/58475486/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index fc32468..5b4b29b 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,10 @@ A `FileUploadResult` object is passed to the success callback of the - __withCredentials__: _boolean_ that tells the browser to set the withCredentials flag on the XMLHttpRequest +### Windows Quirks + +- An option parameter with empty/null value is excluded in the upload operation due to the Windows API design. + ## download __Parameters__: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/58475486/src/windows/FileTransferProxy.js ---------------------------------------------------------------------- diff --git a/src/windows/FileTransferProxy.js b/src/windows/FileTransferProxy.js index 1a506e6..56df315 100644 --- a/src/windows/FileTransferProxy.js +++ b/src/windows/FileTransferProxy.js @@ -356,7 +356,8 @@ exec(win, fail, 'FileTransfer', 'upload', // adding params supplied to request payload var transferParts = []; for (var key in params) { - if (params.hasOwnProperty(key)) { + // Create content part for params only if value is specified because CreateUploadAsync fails otherwise + if (params.hasOwnProperty(key) && params[key] !== null && params[key] !== undefined && params[key].toString() !== "") { var contentPart = new Windows.Networking.BackgroundTransfer.BackgroundTransferContentPart(); contentPart.setHeader("Content-Disposition", "form-data; name=\"" + key + "\""); contentPart.setText(params[key]); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
