|
|
|
|
54
|
self.respData = [[NSMutableData alloc] initWithLength:0];
|
54
|
self.respData = [[NSMutableData alloc] initWithLength:0];
|
55
|
self.callback = callback;
|
55
|
self.callback = callback;
|
56
|
self.bridge = bridgeRef;
|
56
|
self.bridge = bridgeRef;
|
|
|
57
|
+ self.expectedBytes = 0;
|
|
|
58
|
+ self.receivedBytes = 0;
|
57
|
// Call long-running code on background thread
|
59
|
// Call long-running code on background thread
|
58
|
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:NO];
|
60
|
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:NO];
|
59
|
[conn scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
61
|
[conn scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
|
|
|
|
74
|
}
|
76
|
}
|
75
|
|
77
|
|
76
|
- (void) connection:(NSURLConnection *)connection didReceiveData:(nonnull NSData *)data {
|
78
|
- (void) connection:(NSURLConnection *)connection didReceiveData:(nonnull NSData *)data {
|
77
|
- receivedBytes = data.length;
|
|
|
|
|
79
|
+ receivedBytes += data.length;
|
78
|
[respData appendData:data];
|
80
|
[respData appendData:data];
|
79
|
|
81
|
|
80
|
[self.bridge.eventDispatcher
|
82
|
[self.bridge.eventDispatcher
|
|
|
|
|
90
|
- (void) connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
|
92
|
- (void) connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
|
91
|
|
93
|
|
92
|
expectedBytes = totalBytesExpectedToWrite;
|
94
|
expectedBytes = totalBytesExpectedToWrite;
|
93
|
- receivedBytes = totalBytesWritten;
|
|
|
|
|
95
|
+ receivedBytes += totalBytesWritten;
|
94
|
[self.bridge.eventDispatcher
|
96
|
[self.bridge.eventDispatcher
|
95
|
sendAppEventWithName:@"RNFetchBlobProgress"
|
97
|
sendAppEventWithName:@"RNFetchBlobProgress"
|
96
|
body:@{
|
98
|
body:@{
|