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

Commit 305bda6

Browse files
committed
merge
1 parent a510c11 commit 305bda6

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

src/ios/RNFetchBlob/RNFetchBlob.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ - (NSDictionary *)constantsToExport
367367
[RNFetchBlobFS slice:src dest:dest start:start end:end encode:@"" resolver:resolve rejecter:reject];
368368
})
369369

370+
RCT_EXPORT_METHOD(openFile:(NSString*)uri {
371+
[[[RNFetchBlobFS alloc ] init ]openFile:uri];
372+
})
373+
370374
#pragma mark RNFetchBlob private methods
371375

372376

src/ios/RNFetchBlobFS.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
#import <Foundation/Foundation.h>
1313
#import "RCTBridgeModule.h"
14+
#import <UIKit/UIKit.h>
1415
@import AssetsLibrary;
1516

16-
@interface RNFetchBlobFS : NSObject <NSStreamDelegate> {
17+
@interface RNFetchBlobFS : NSObject <NSStreamDelegate, UIDocumentInteractionControllerDelegate> {
1718
NSOutputStream * outStream;
1819
NSInputStream * inStream;
1920
RCTResponseSenderBlock callback;
@@ -82,6 +83,8 @@
8283
- (void) closeInStream;
8384
- (void) closeOutStream;
8485

86+
- (void) openFile:( NSString * _Nonnull ) uri;
87+
8588
@end
8689

8790
#endif /* RNFetchBlobFS_h */

src/ios/RNFetchBlobFS.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,4 +730,19 @@ + (void) getPathFromUri:(NSString *)uri completionHandler:(void(^)(NSString * pa
730730
}
731731
}
732732

733+
# pragma mark - open file with UIDocumentInteractionController and delegate
734+
735+
- (void) openFile:(NSString *) uri
736+
{
737+
NSURL * url = [[NSURL alloc] initWithString:uri];
738+
UIDocumentInteractionController * docCtrl = [UIDocumentInteractionController interactionControllerWithURL:url];
739+
docCtrl.delegate = self;
740+
[docCtrl presentPreviewAnimated:YES];
741+
742+
}
743+
744+
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
745+
return self;
746+
}
747+
733748
@end

test/test-init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ describe('GET image from server', (report, done) => {
6969
// require('./test-0.9.0')
7070
// require('./test-0.9.2')
7171
require('./test-0.10.0')
72+
// require('./test-0.9.4')
7273
// require('./test-fetch')
7374
// require('./test-fs')
7475
// require('./test-xmlhttp')

0 commit comments

Comments
 (0)