@@ -36,6 +36,23 @@ @implementation RNFetchBlobFS
36
36
@synthesize appendData;
37
37
@synthesize bufferSize;
38
38
39
+ - (id )init {
40
+ self = [super init ];
41
+ return self;
42
+ }
43
+
44
+ - (id )initWithCallback : (RCTResponseSenderBlock)callback {
45
+ self = [super init ];
46
+ self.callback = callback;
47
+ return self;
48
+ }
49
+
50
+ - (id )initWithBridgeRef : (RCTBridge *)bridgeRef {
51
+ self = [super init ];
52
+ self.bridge = bridgeRef;
53
+ return self;
54
+ }
55
+
39
56
// static member getter
40
57
+ (NSArray *) getFileStreams {
41
58
@@ -118,6 +135,13 @@ + (void) readStream:(NSString *)uri
118
135
119
136
if (path != nil )
120
137
{
138
+ if ([[NSFileManager defaultManager ] fileExistsAtPath: path] == NO )
139
+ {
140
+ NSString * message = [NSString stringWithFormat: @" File not exists at path %@ " , path];
141
+ NSDictionary * payload = @{ @" event" : FS_EVENT_ERROR, @" detail" : message };
142
+ [event sendDeviceEventWithName: streamId body: payload];
143
+ return ;
144
+ }
121
145
NSInputStream * stream = [[NSInputStream alloc ] initWithFileAtPath: path];
122
146
[stream open ];
123
147
while ((read = [stream read: buffer maxLength: bufferSize]) > 0 )
@@ -144,7 +168,6 @@ + (void) readStream:(NSString *)uri
144
168
}
145
169
@catch (NSError * err)
146
170
{
147
-
148
171
NSDictionary * payload = @{ @" event" : FS_EVENT_ERROR, @" detail" : [NSString stringWithFormat: @" RNFetchBlob.readStream error %@ " , [err description ]] };
149
172
[event sendDeviceEventWithName: streamId body: payload];
150
173
}
@@ -471,23 +494,6 @@ + (void) exists:(NSString *) path callback:(RCTResponseSenderBlock)callback
471
494
}];
472
495
}
473
496
474
- - (id )init {
475
- self = [super init ];
476
- return self;
477
- }
478
-
479
- - (id )initWithCallback : (RCTResponseSenderBlock)callback {
480
- self = [super init ];
481
- self.callback = callback;
482
- return self;
483
- }
484
-
485
- - (id )initWithBridgeRef : (RCTBridge *)bridgeRef {
486
- self = [super init ];
487
- self.bridge = bridgeRef;
488
- return self;
489
- }
490
-
491
497
# pragma mark - open file stream
492
498
493
499
// Create file stream for write data
0 commit comments