You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2012/09/21 05:15:05 UTC

[5/7] ios commit: [CB-622] Added upload progress to FileTransfer

[CB-622] Added upload progress to FileTransfer


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/de69937e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/de69937e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/de69937e

Branch: refs/heads/master
Commit: de69937e7e987ef6648a6e3623d0febea5bef513
Parents: 33afb30
Author: Cory Thompson <co...@gmail.com>
Authored: Thu Aug 9 12:23:40 2012 +1000
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Sep 20 22:34:27 2012 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVFileTransfer.m |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/de69937e/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index b7e8e8c..773d34f 100755
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -478,6 +478,17 @@ static NSMutableArray* _abortTriggered = nil;
         [_abortTriggered removeObject:self.objectId];
         return;
     }
+    
+    NSMutableDictionary* uploadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
+    CDVPluginResult* result;
+    
+    [uploadProgress setObject:[NSNumber numberWithBool: true] forKey:@"lengthComputable"];
+    [uploadProgress setObject:[NSNumber numberWithInt: totalBytesWritten] forKey:@"loaded"];
+    [uploadProgress setObject:[NSNumber numberWithInt: totalBytesExpectedToWrite] forKey:@"total"];
+    result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: uploadProgress ];
+    [result setKeepCallbackAsBool:true]; 
+    [self.command writeJavascript:[result toSuccessCallbackString: callbackId ]];
+    
     self.bytesWritten = totalBytesWritten;
 }
 /* TESTING ONLY CODE