Merge pull request #45 from magicismight/master

fix error caused by when `bytesWritten` is null
This commit is contained in:
Chris Dell 2016-01-20 08:53:48 +00:00
commit 8ef4fa1f65
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) {