Skip to content

Commit 94db667

Browse files
committed
Merge branch 'master' of github.com:wkh237/react-native-fetch-blob
2 parents 3245022 + 3c14c8c commit 94db667

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,14 @@ public void onReceive(Context context, Intent intent) {
641641
return;
642642
}
643643
String contentUri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
644-
Uri uri = Uri.parse(contentUri);
645-
Cursor cursor = appCtx.getContentResolver().query(uri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null);
646-
// use default destination of DownloadManager
647-
if (cursor != null) {
648-
cursor.moveToFirst();
649-
filePath = cursor.getString(0);
644+
if (contentUri != null) {
645+
Uri uri = Uri.parse(contentUri);
646+
Cursor cursor = appCtx.getContentResolver().query(uri, new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null);
647+
// use default destination of DownloadManager
648+
if (cursor != null) {
649+
cursor.moveToFirst();
650+
filePath = cursor.getString(0);
651+
}
650652
}
651653
}
652654
// When the file is not found in media content database, check if custom path exists

ios/RNFetchBlob/RNFetchBlob.m

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ - (NSDictionary *)constantsToExport
314314
#pragma mark - fs.stat
315315
RCT_EXPORT_METHOD(stat:(NSString *)target callback:(RCTResponseSenderBlock) callback)
316316
{
317-
317+
318318
[RNFetchBlobFS getPathFromUri:target completionHandler:^(NSString *path, ALAssetRepresentation *asset) {
319319
__block NSMutableArray * result;
320320
if(path != nil)
@@ -323,14 +323,14 @@ - (NSDictionary *)constantsToExport
323323
BOOL exist = nil;
324324
BOOL isDir = nil;
325325
NSError * error = nil;
326-
326+
327327
exist = [fm fileExistsAtPath:path isDirectory:&isDir];
328328
if(exist == NO) {
329329
callback(@[[NSString stringWithFormat:@"failed to stat path `%@` for it is not exist or it is not exist", path]]);
330330
return ;
331331
}
332332
result = [RNFetchBlobFS stat:path error:&error];
333-
333+
334334
if(error == nil)
335335
callback(@[[NSNull null], result]);
336336
else
@@ -389,7 +389,7 @@ - (NSDictionary *)constantsToExport
389389
#pragma mark - fs.cp
390390
RCT_EXPORT_METHOD(cp:(NSString*)src toPath:(NSString *)dest callback:(RCTResponseSenderBlock) callback)
391391
{
392-
392+
393393
// path = [RNFetchBlobFS getPathOfAsset:path];
394394
[RNFetchBlobFS getPathFromUri:src completionHandler:^(NSString *path, ALAssetRepresentation *asset) {
395395
NSError * error = nil;
@@ -401,14 +401,14 @@ - (NSDictionary *)constantsToExport
401401
else
402402
{
403403
BOOL result = [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:path] toURL:[NSURL fileURLWithPath:dest] error:&error];
404-
404+
405405
if(error == nil)
406406
callback(@[[NSNull null], @YES]);
407407
else
408408
callback(@[[error localizedDescription], @NO]);
409409
}
410410
}];
411-
411+
412412
}
413413

414414

@@ -470,7 +470,7 @@ - (NSDictionary *)constantsToExport
470470
else
471471
bufferSize = 4096;
472472
}
473-
473+
474474
dispatch_async(fsQueue, ^{
475475
[RNFetchBlobFS readStream:path encoding:encoding bufferSize:bufferSize tick:tick streamId:streamId bridgeRef:_bridge];
476476
});
@@ -496,7 +496,7 @@ - (NSDictionary *)constantsToExport
496496
#pragma mark - net.enableProgressReport
497497
RCT_EXPORT_METHOD(enableProgressReport:(NSString *)taskId interval:(nonnull NSNumber*)interval count:(nonnull NSNumber*)count)
498498
{
499-
499+
500500
RNFetchBlobProgress * cfg = [[RNFetchBlobProgress alloc] initWithType:Download interval:interval count:count];
501501
[RNFetchBlobNetwork enableProgressReport:taskId config:cfg];
502502
}
@@ -523,9 +523,10 @@ - (NSDictionary *)constantsToExport
523523
UIViewController *rootCtrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
524524
documentController.delegate = self;
525525
if(scheme == nil || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) {
526-
dispatch_sync(dispatch_get_main_queue(), ^{
527-
[documentController presentOptionsMenuFromRect:rootCtrl.view.bounds inView:rootCtrl.view animated:YES];
528-
});
526+
CGRect rect = CGRectMake(0.0, 0.0, 0.0, 0.0);
527+
dispatch_sync(dispatch_get_main_queue(), ^{
528+
[documentController presentOptionsMenuFromRect:rect inView:rootCtrl.view animated:YES];
529+
});
529530
resolve(@[[NSNull null]]);
530531
} else {
531532
reject(@"RNFetchBlob could not open document", @"scheme is not supported", nil);
@@ -541,7 +542,7 @@ - (NSDictionary *)constantsToExport
541542
// NSURL * url = [[NSURL alloc] initWithString:uri];
542543
documentController = [UIDocumentInteractionController interactionControllerWithURL:url];
543544
documentController.delegate = self;
544-
545+
545546
if(scheme == nil || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) {
546547
dispatch_sync(dispatch_get_main_queue(), ^{
547548
[documentController presentPreviewAnimated:YES];
@@ -564,7 +565,7 @@ - (NSDictionary *)constantsToExport
564565
} else {
565566
reject(@"RNFetchBlob could not open document", [error description], nil);
566567
}
567-
568+
568569
}
569570

570571

0 commit comments

Comments
 (0)