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

Commit 335d83d

Browse files
stevelileswkh237
authored andcommitted
simplest possible fix for #311 (#313)
1 parent 016a480 commit 335d83d

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

ios/RNFetchBlob/RNFetchBlob.m

+14-13
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ - (NSDictionary *)constantsToExport
300300
#pragma mark - fs.stat
301301
RCT_EXPORT_METHOD(stat:(NSString *)target callback:(RCTResponseSenderBlock) callback)
302302
{
303-
303+
304304
[RNFetchBlobFS getPathFromUri:target completionHandler:^(NSString *path, ALAssetRepresentation *asset) {
305305
__block NSMutableArray * result;
306306
if(path != nil)
@@ -309,14 +309,14 @@ - (NSDictionary *)constantsToExport
309309
BOOL exist = nil;
310310
BOOL isDir = nil;
311311
NSError * error = nil;
312-
312+
313313
exist = [fm fileExistsAtPath:path isDirectory:&isDir];
314314
if(exist == NO) {
315315
callback(@[[NSString stringWithFormat:@"failed to stat path `%@` for it is not exist or it is not exist", path]]);
316316
return ;
317317
}
318318
result = [RNFetchBlobFS stat:path error:&error];
319-
319+
320320
if(error == nil)
321321
callback(@[[NSNull null], result]);
322322
else
@@ -375,7 +375,7 @@ - (NSDictionary *)constantsToExport
375375
#pragma mark - fs.cp
376376
RCT_EXPORT_METHOD(cp:(NSString*)src toPath:(NSString *)dest callback:(RCTResponseSenderBlock) callback)
377377
{
378-
378+
379379
// path = [RNFetchBlobFS getPathOfAsset:path];
380380
[RNFetchBlobFS getPathFromUri:src completionHandler:^(NSString *path, ALAssetRepresentation *asset) {
381381
NSError * error = nil;
@@ -387,14 +387,14 @@ - (NSDictionary *)constantsToExport
387387
else
388388
{
389389
BOOL result = [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:path] toURL:[NSURL fileURLWithPath:dest] error:&error];
390-
390+
391391
if(error == nil)
392392
callback(@[[NSNull null], @YES]);
393393
else
394394
callback(@[[error localizedDescription], @NO]);
395395
}
396396
}];
397-
397+
398398
}
399399

400400

@@ -456,7 +456,7 @@ - (NSDictionary *)constantsToExport
456456
else
457457
bufferSize = 4096;
458458
}
459-
459+
460460
dispatch_async(fsQueue, ^{
461461
[RNFetchBlobFS readStream:path encoding:encoding bufferSize:bufferSize tick:tick streamId:streamId bridgeRef:_bridge];
462462
});
@@ -482,7 +482,7 @@ - (NSDictionary *)constantsToExport
482482
#pragma mark - net.enableProgressReport
483483
RCT_EXPORT_METHOD(enableProgressReport:(NSString *)taskId interval:(nonnull NSNumber*)interval count:(nonnull NSNumber*)count)
484484
{
485-
485+
486486
RNFetchBlobProgress * cfg = [[RNFetchBlobProgress alloc] initWithType:Download interval:interval count:count];
487487
[RNFetchBlobNetwork enableProgressReport:taskId config:cfg];
488488
}
@@ -509,9 +509,10 @@ - (NSDictionary *)constantsToExport
509509
UIViewController *rootCtrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
510510
documentController.delegate = self;
511511
if(scheme == nil || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) {
512-
dispatch_sync(dispatch_get_main_queue(), ^{
513-
[documentController presentOptionsMenuFromRect:rootCtrl.view.bounds inView:rootCtrl.view animated:YES];
514-
});
512+
CGRect rect = CGRectMake(0.0, 0.0, 0.0, 0.0);
513+
dispatch_sync(dispatch_get_main_queue(), ^{
514+
[documentController presentOptionsMenuFromRect:rect inView:rootCtrl.view animated:YES];
515+
});
515516
resolve(@[[NSNull null]]);
516517
} else {
517518
reject(@"RNFetchBlob could not open document", @"scheme is not supported", nil);
@@ -527,7 +528,7 @@ - (NSDictionary *)constantsToExport
527528
// NSURL * url = [[NSURL alloc] initWithString:uri];
528529
documentController = [UIDocumentInteractionController interactionControllerWithURL:url];
529530
documentController.delegate = self;
530-
531+
531532
if(scheme == nil || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) {
532533
dispatch_sync(dispatch_get_main_queue(), ^{
533534
[documentController presentPreviewAnimated:YES];
@@ -550,7 +551,7 @@ - (NSDictionary *)constantsToExport
550551
} else {
551552
reject(@"RNFetchBlob could not open document", [error description], nil);
552553
}
553-
554+
554555
}
555556

556557

0 commit comments

Comments
 (0)