cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject cordova-plugin-file-transfer git commit: CB-8589 Fixes upload failure when server's response doesn't contain any data
Date Thu, 02 Apr 2015 10:42:03 GMT
Repository: cordova-plugin-file-transfer
Updated Branches:
  refs/heads/master a868e04b2 -> 6ed66a4f2


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/master
Commit: 6ed66a4f298c18769f95bf57a7682719729b29f7
Parents: a868e04
Author: Vladimir Kotikov <v-vlkoti@microsoft.com>
Authored: Mon Mar 30 13:56:51 2015 +0300
Committer: Vladimir Kotikov <v-vlkoti@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


Mime
View raw message