Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit d0455c9

Browse files
committed
#1 correct ios progress report value
1 parent f172167 commit d0455c9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ios/RNFetchBlob/RNFetchBlob.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ - (void) sendRequest:(RCTBridge *)bridgeRef taskId:(NSString *)taskId withReques
5454
self.respData = [[NSMutableData alloc] initWithLength:0];
5555
self.callback = callback;
5656
self.bridge = bridgeRef;
57+
self.expectedBytes = 0;
58+
self.receivedBytes = 0;
5759
// Call long-running code on background thread
5860
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:NO];
5961
[conn scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
@@ -74,7 +76,7 @@ - (void) connection:(NSURLConnection *)connection didReceiveResponse:(nonnull NS
7476
}
7577

7678
- (void) connection:(NSURLConnection *)connection didReceiveData:(nonnull NSData *)data {
77-
receivedBytes = data.length;
79+
receivedBytes += data.length;
7880
[respData appendData:data];
7981

8082
[self.bridge.eventDispatcher
@@ -90,7 +92,7 @@ - (void) connection:(NSURLConnection *)connection didReceiveData:(nonnull NSData
9092
- (void) connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
9193

9294
expectedBytes = totalBytesExpectedToWrite;
93-
receivedBytes = totalBytesWritten;
95+
receivedBytes += totalBytesWritten;
9496
[self.bridge.eventDispatcher
9597
sendAppEventWithName:@"RNFetchBlobProgress"
9698
body:@{

0 commit comments

Comments
 (0)