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 2016/12/06 14:24:34 UTC

cordova-plugin-file-transfer git commit: CB-12154 file-transfer progressEvent.total = -1 on iOS

Repository: cordova-plugin-file-transfer
Updated Branches:
  refs/heads/master 655489905 -> 5a711e872


CB-12154 file-transfer progressEvent.total = -1 on iOS

Makes chunkedMode=true uploads to contain Content-Length to make progress computable


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

Branch: refs/heads/master
Commit: 5a711e8722804d4d427fa5e580c9e6767c8a6cee
Parents: 6554899
Author: daserge <v-...@microsoft.com>
Authored: Wed Nov 23 18:57:11 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Tue Dec 6 17:06:00 2016 +0300

----------------------------------------------------------------------
 src/ios/CDVFileTransfer.m | 5 +++--
 tests/tests.js            | 4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/5a711e87/src/ios/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m
index 6024901..9b01049 100644
--- a/src/ios/CDVFileTransfer.m
+++ b/src/ios/CDVFileTransfer.m
@@ -229,6 +229,8 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
         totalPayloadLength += [postBodyBeforeFile length] + [postBodyAfterFile length];
     }
 
+    [req setValue:[[NSNumber numberWithLongLong:totalPayloadLength] stringValue] forHTTPHeaderField:@"Content-Length"];
+
     if (chunkedMode) {
         CFReadStreamRef readStream = NULL;
         CFWriteStreamRef writeStream = NULL;
@@ -266,7 +268,6 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
             CFRelease(writeStream);
         }];
     } else {
-        [req setValue:[[NSNumber numberWithLongLong:totalPayloadLength] stringValue] forHTTPHeaderField:@"Content-Length"];
         if (multipartFormUpload) {
             [postBodyBeforeFile appendData:fileData];
             [postBodyBeforeFile appendData:postBodyAfterFile];
@@ -814,7 +815,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
     if (self.direction == CDV_TRANSFER_UPLOAD) {
         NSMutableDictionary* uploadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
 
-        [uploadProgress setObject:[NSNumber numberWithBool:(!self.chunkedMode)] forKey:@"lengthComputable"];
+        [uploadProgress setObject:[NSNumber numberWithBool:true] forKey:@"lengthComputable"];
         [uploadProgress setObject:[NSNumber numberWithLongLong:totalBytesWritten] forKey:@"loaded"];
         [uploadProgress setObject:[NSNumber numberWithLongLong:totalBytesExpectedToWrite] forKey:@"total"];
         CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadProgress];

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/5a711e87/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 7149091..e303b45 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -1506,7 +1506,9 @@ exports.defineAutoTests = function () {
                             obj = JSON.parse(uploadResult.response);
 
                             if (specContext.uploadOptions.chunkedMode) {
-                                expect(obj["content-length"]).not.toBeDefined("Expected Content-Length not to be defined");
+                                if (!isIos) {
+                                    expect(obj["content-length"]).not.toBeDefined("Expected Content-Length not to be defined");
+                                }
                                 expect(obj["transfer-encoding"].toLowerCase()).toEqual("chunked");
                             } else {
                                 expect(obj["content-length"]).toBeDefined("Expected Content-Length to be defined");


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