You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/04/10 01:13:49 UTC

[2/6] cordova-plugin-file-transfer git commit: CB-8589 Fixes upload failure when server's response doesn't contain any data

CB-8589 Fixes upload failure when server's response doesn't contain any data


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/6ed66a4f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/6ed66a4f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/6ed66a4f

Branch: refs/heads/old-ID
Commit: 6ed66a4f298c18769f95bf57a7682719729b29f7
Parents: a868e04
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Mon Mar 30 13:56:51 2015 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Thu Apr 2 13:41:12 2015 +0300

----------------------------------------------------------------------
 src/windows/FileTransferProxy.js | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/6ed66a4f/src/windows/FileTransferProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/FileTransferProxy.js b/src/windows/FileTransferProxy.js
index 39c7c24..3dcf29e 100644
--- a/src/windows/FileTransferProxy.js
+++ b/src/windows/FileTransferProxy.js
@@ -161,11 +161,18 @@ exec(win, fail, 'FileTransfer', 'upload',
                                 }
 
                                 var response = result.getResponseInformation();
-                                // creating a data reader, attached to response stream to get server's response
+                                var ftResult = new FileUploadResult(result.progress.bytesSent, response.statusCode, '');
+
+                                // if server's response doesn't contain any data, then resolve operation now
+                                if (result.progress.bytesReceived === 0) {
+                                    successCallback(ftResult);
+                                    return;
+                                }
+
+                                // otherwise create a data reader, attached to response stream to get server's response
                                 var reader = new Windows.Storage.Streams.DataReader(result.getResultStreamAt(0));
-                                reader.loadAsync(result.progress.bytesReceived).then(function(size) {
-                                    var responseText = reader.readString(size);
-                                    var ftResult = new FileUploadResult(size, response.statusCode, responseText);
+                                reader.loadAsync(result.progress.bytesReceived).then(function (size) {
+                                    ftResult.response = reader.readString(size);
                                     successCallback(ftResult);
                                     reader.close();
                                 });


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org