Pārlūkot izejas kodu

Merge pull request #79 from jbrodriguez/master

Fix callback signature
wkh237 8 gadus atpakaļ
vecāks
revīzija
28e4b338d2

+ 1
- 1
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java Parādīt failu

165
            File file = new File(RNFetchBlobFS.getTmpPath(RNFetchBlob.RCTContext, cacheKey) + ext);
165
            File file = new File(RNFetchBlobFS.getTmpPath(RNFetchBlob.RCTContext, cacheKey) + ext);
166
 
166
 
167
            if (file.exists()) {
167
            if (file.exists()) {
168
-               callback.invoke(null, file.getAbsolutePath());
168
+               callback.invoke(null, null, file.getAbsolutePath());
169
                return;
169
                return;
170
            }
170
            }
171
        }
171
        }

+ 9
- 9
src/ios/RNFetchBlobNetwork.m Parādīt failu

133
 
133
 
134
     // the session trust any SSL certification
134
     // the session trust any SSL certification
135
 
135
 
136
-    
136
+
137
     NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
137
     NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
138
     if([options valueForKey:@"timeout"] != nil)
138
     if([options valueForKey:@"timeout"] != nil)
139
     {
139
     {
153
 
153
 
154
 			destPath = [RNFetchBlobFS getTempPath:cacheKey withExtension:[self.options valueForKey:CONFIG_FILE_EXT]];
154
 			destPath = [RNFetchBlobFS getTempPath:cacheKey withExtension:[self.options valueForKey:CONFIG_FILE_EXT]];
155
             if ([[NSFileManager defaultManager] fileExistsAtPath:destPath]) {
155
             if ([[NSFileManager defaultManager] fileExistsAtPath:destPath]) {
156
-				callback(@[[NSNull null], destPath]);
156
+				callback(@[[NSNull null], @[[NSNull null], destPath]);
157
                 return;
157
                 return;
158
             }
158
             }
159
 		}
159
 		}
190
 - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler
190
 - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler
191
 {
191
 {
192
     expectedBytes = [response expectedContentLength];
192
     expectedBytes = [response expectedContentLength];
193
- 
193
+
194
     NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
194
     NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
195
     NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
195
     NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
196
     if ([response respondsToSelector:@selector(allHeaderFields)])
196
     if ([response respondsToSelector:@selector(allHeaderFields)])
229
                      @"timeout" : @NO,
229
                      @"timeout" : @NO,
230
                      @"status": [NSString stringWithFormat:@"%d", statusCode ]
230
                      @"status": [NSString stringWithFormat:@"%d", statusCode ]
231
                      };
231
                      };
232
-        
232
+
233
         [self.bridge.eventDispatcher
233
         [self.bridge.eventDispatcher
234
          sendDeviceEventWithName: EVENT_STATE_CHANGE
234
          sendDeviceEventWithName: EVENT_STATE_CHANGE
235
          body:respInfo
235
          body:respInfo
272
     {
272
     {
273
         [writeStream write:[data bytes] maxLength:[data length]];
273
         [writeStream write:[data bytes] maxLength:[data length]];
274
     }
274
     }
275
-    
275
+
276
     if([progressTable valueForKey:taskId] == @YES)
276
     if([progressTable valueForKey:taskId] == @YES)
277
     {
277
     {
278
         [self.bridge.eventDispatcher
278
         [self.bridge.eventDispatcher
296
 
296
 
297
 - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
297
 - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
298
 {
298
 {
299
-    
299
+
300
     self.error = error;
300
     self.error = error;
301
     [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
301
     [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
302
-    
302
+
303
     NSString * respType = [respInfo valueForKey:@"respType"];
303
     NSString * respType = [respInfo valueForKey:@"respType"];
304
     if(error != nil) {
304
     if(error != nil) {
305
         NSLog([error localizedDescription]);
305
         NSLog([error localizedDescription]);
306
     }
306
     }
307
-    
307
+
308
     if(respFile == YES)
308
     if(respFile == YES)
309
     {
309
     {
310
         [writeStream close];
310
         [writeStream close];
321
                    [respData base64EncodedStringWithOptions:0]
321
                    [respData base64EncodedStringWithOptions:0]
322
                    ]);
322
                    ]);
323
     }
323
     }
324
-    
324
+
325
     [taskTable removeObjectForKey:taskId];
325
     [taskTable removeObjectForKey:taskId];
326
     [uploadProgressTable removeObjectForKey:taskId];
326
     [uploadProgressTable removeObjectForKey:taskId];
327
     [progressTable removeObjectForKey:taskId];
327
     [progressTable removeObjectForKey:taskId];