fix error caused by `bytesWritten` is null

fix error  caused by `bytesWritten` is null
This commit is contained in:
Horcrux 2016-01-20 12:00:34 +08:00
parent ce98cba66f
commit 65ab7914b3
1 changed files with 6 additions and 3 deletions

View File

@ -160,9 +160,12 @@ RCT_EXPORT_METHOD(downloadFile:(NSString *)urlStr
params.toFile = filepath;
params.callback = ^(NSNumber* statusCode, NSNumber* bytesWritten) {
return callback(@[[NSNull null], @{@"jobId": jobId,
@"statusCode": statusCode,
@"bytesWritten": bytesWritten}]);
NSMutableDictionary* result = [[NSMutableDictionary alloc] initWithDictionary: @{@"jobId": jobId,
@"statusCode": statusCode}];
if (bytesWritten) {
[result setObject:@"bytesWritten" forKey: bytesWritten];
}
return callback(@[[NSNull null], result]);
};
params.errorCallback = ^(NSError* error) {