| 
				
			 | 
			
			
				@@ -37,7 +37,7 @@ NSMutableDictionary *fileStreams = nil; 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				37
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				38
			 | 
			
				38
			 | 
			
			
				 // static member getter 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				39
			 | 
			
			
				 + (NSArray *) getFileStreams { 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				41
			 | 
			
			
				     if(fileStreams == nil) 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				42
			 | 
			
			
				         fileStreams = [[NSMutableDictionary alloc] init]; 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				43
			 | 
			
			
				     return fileStreams; 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -70,12 +70,12 @@ NSMutableDictionary *fileStreams = nil; 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				70
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				71
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				72
			 | 
			
				72
			 | 
			
			
				 + (NSString *) getTempPath { 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				74
			 | 
			
			
				     return [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingString:@"/RNFetchBlob_tmp"]; 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				75
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				76
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				77
			 | 
			
				77
			 | 
			
			
				 + (NSString *) getTempPath:(NSString*)taskId withExtension:(NSString *)ext { 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				79
			 | 
			
			
				     NSString * documentDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				80
			 | 
			
			
				     NSString * filename = [NSString stringWithFormat:@"/RNFetchBlob_tmp/RNFetchBlobTmp_%@", taskId]; 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				81
			 | 
			
			
				     if(ext != nil) 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -173,7 +173,7 @@ NSMutableDictionary *fileStreams = nil; 
			 | 
		
	
		
			
			| 
				173
			 | 
			
				173
			 | 
			
			
				             } 
			 | 
		
	
		
			
			| 
				174
			 | 
			
				174
			 | 
			
			
				             resolve(resultArray); 
			 | 
		
	
		
			
			| 
				175
			 | 
			
				175
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				176
			 | 
			
				
			 | 
			
			
				-         
			 | 
		
	
		
			
			| 
				
			 | 
			
				176
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				177
			 | 
			
				177
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				178
			 | 
			
				178
			 | 
			
			
				     @catch(NSException * e) 
			 | 
		
	
		
			
			| 
				179
			 | 
			
				179
			 | 
			
			
				     { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -289,17 +289,17 @@ NSMutableDictionary *fileStreams = nil; 
			 | 
		
	
		
			
			| 
				289
			 | 
			
				289
			 | 
			
			
				         [self.outStream close]; 
			 | 
		
	
		
			
			| 
				290
			 | 
			
				290
			 | 
			
			
				         self.outStream = nil; 
			 | 
		
	
		
			
			| 
				291
			 | 
			
				291
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				292
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				292
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				293
			 | 
			
				293
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				294
			 | 
			
				294
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				295
			 | 
			
				295
			 | 
			
			
				 - (void)readWithPath:(NSString *)path useEncoding:(NSString *)encoding bufferSize:(int) bufferSize { 
			 | 
		
	
		
			
			| 
				296
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				296
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				297
			 | 
			
				297
			 | 
			
			
				     self.inStream = [[NSInputStream alloc] initWithFileAtPath:path]; 
			 | 
		
	
		
			
			| 
				298
			 | 
			
				298
			 | 
			
			
				     self.inStream.delegate = self; 
			 | 
		
	
		
			
			| 
				299
			 | 
			
				299
			 | 
			
			
				     self.encoding = encoding; 
			 | 
		
	
		
			
			| 
				300
			 | 
			
				300
			 | 
			
			
				     self.path = path; 
			 | 
		
	
		
			
			| 
				301
			 | 
			
				301
			 | 
			
			
				     self.bufferSize = bufferSize; 
			 | 
		
	
		
			
			| 
				302
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				302
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				303
			 | 
			
				303
			 | 
			
			
				     // NSStream needs a runloop so let's create a run loop for it 
			 | 
		
	
		
			
			| 
				304
			 | 
			
				304
			 | 
			
			
				     dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0); 
			 | 
		
	
		
			
			| 
				305
			 | 
			
				305
			 | 
			
			
				     // start NSStream is a runloop 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -308,7 +308,7 @@ NSMutableDictionary *fileStreams = nil; 
			 | 
		
	
		
			
			| 
				308
			 | 
			
				308
			 | 
			
			
				                             forMode:NSDefaultRunLoopMode]; 
			 | 
		
	
		
			
			| 
				309
			 | 
			
				309
			 | 
			
			
				         [inStream open]; 
			 | 
		
	
		
			
			| 
				310
			 | 
			
				310
			 | 
			
			
				         [[NSRunLoop currentRunLoop] run]; 
			 | 
		
	
		
			
			| 
				311
			 | 
			
				
			 | 
			
			
				-         
			 | 
		
	
		
			
			| 
				
			 | 
			
				311
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				312
			 | 
			
				312
			 | 
			
			
				     }); 
			 | 
		
	
		
			
			| 
				313
			 | 
			
				313
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				314
			 | 
			
				314
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -320,7 +320,7 @@ NSMutableDictionary *fileStreams = nil; 
			 | 
		
	
		
			
			| 
				320
			 | 
			
				320
			 | 
			
			
				         [[RNFetchBlobFS getFileStreams] setValue:nil forKey:self.streamId]; 
			 | 
		
	
		
			
			| 
				321
			 | 
			
				321
			 | 
			
			
				         self.streamId = nil; 
			 | 
		
	
		
			
			| 
				322
			 | 
			
				322
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				323
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				323
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				324
			 | 
			
				324
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				325
			 | 
			
				325
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				326
			 | 
			
				326
			 | 
			
			
				 void runOnMainQueueWithoutDeadlocking(void (^block)(void)) 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -339,18 +339,18 @@ void runOnMainQueueWithoutDeadlocking(void (^block)(void)) 
			 | 
		
	
		
			
			| 
				339
			 | 
			
				339
			 | 
			
			
				 #pragma mark RNFetchBlobFS read stream delegate 
			 | 
		
	
		
			
			| 
				340
			 | 
			
				340
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				341
			 | 
			
				341
			 | 
			
			
				 - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode { 
			 | 
		
	
		
			
			| 
				342
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				342
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				343
			 | 
			
				343
			 | 
			
			
				     NSString * streamEventCode = [NSString stringWithFormat:@"RNFetchBlobStream+%@", self.path]; 
			 | 
		
	
		
			
			| 
				344
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				344
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				345
			 | 
			
				345
			 | 
			
			
				     switch(eventCode) { 
			 | 
		
	
		
			
			| 
				346
			 | 
			
				
			 | 
			
			
				-             
			 | 
		
	
		
			
			| 
				
			 | 
			
				346
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				347
			 | 
			
				347
			 | 
			
			
				             // write stream event 
			 | 
		
	
		
			
			| 
				348
			 | 
			
				348
			 | 
			
			
				         case NSStreamEventHasSpaceAvailable: 
			 | 
		
	
		
			
			| 
				349
			 | 
			
				349
			 | 
			
			
				         { 
			 | 
		
	
		
			
			| 
				350
			 | 
			
				
			 | 
			
			
				-             
			 | 
		
	
		
			
			| 
				351
			 | 
			
				
			 | 
			
			
				-             
			 | 
		
	
		
			
			| 
				
			 | 
			
				350
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				351
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				352
			 | 
			
				352
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				353
			 | 
			
				
			 | 
			
			
				-             
			 | 
		
	
		
			
			| 
				
			 | 
			
				353
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				354
			 | 
			
				354
			 | 
			
			
				             // read stream incoming chunk 
			 | 
		
	
		
			
			| 
				355
			 | 
			
				355
			 | 
			
			
				         case NSStreamEventHasBytesAvailable: 
			 | 
		
	
		
			
			| 
				356
			 | 
			
				356
			 | 
			
			
				         { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -360,7 +360,8 @@ void runOnMainQueueWithoutDeadlocking(void (^block)(void)) 
			 | 
		
	
		
			
			| 
				360
			 | 
			
				360
			 | 
			
			
				                 chunkSize = 4095; 
			 | 
		
	
		
			
			| 
				361
			 | 
			
				361
			 | 
			
			
				             if(self.bufferSize > 0) 
			 | 
		
	
		
			
			| 
				362
			 | 
			
				362
			 | 
			
			
				                 chunkSize = self.bufferSize; 
			 | 
		
	
		
			
			| 
				363
			 | 
			
				
			 | 
			
			
				-            uint8_t * buf = (uint8_t *)malloc(chunkSize); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				363
			 | 
			
			
				+//            uint8_t * buf = (uint8_t *)malloc(chunkSize); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				364
			 | 
			
			
				+            uint8_t buf[chunkSize]; 
			 | 
		
	
		
			
			| 
				364
			 | 
			
				365
			 | 
			
			
				             unsigned int len = 0; 
			 | 
		
	
		
			
			| 
				365
			 | 
			
				366
			 | 
			
			
				             len = [(NSInputStream *)stream read:buf maxLength:chunkSize]; 
			 | 
		
	
		
			
			| 
				366
			 | 
			
				367
			 | 
			
			
				             // still have data in stream 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -385,7 +386,7 @@ void runOnMainQueueWithoutDeadlocking(void (^block)(void)) 
			 | 
		
	
		
			
			| 
				385
			 | 
			
				386
			 | 
			
			
				                             [asciiArray addObject:[NSNumber numberWithChar:bytePtr[i]]]; 
			 | 
		
	
		
			
			| 
				386
			 | 
			
				387
			 | 
			
			
				                         } 
			 | 
		
	
		
			
			| 
				387
			 | 
			
				388
			 | 
			
			
				                     } 
			 | 
		
	
		
			
			| 
				388
			 | 
			
				
			 | 
			
			
				-                     
			 | 
		
	
		
			
			| 
				
			 | 
			
				389
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				389
			 | 
			
				390
			 | 
			
			
				                     [self.bridge.eventDispatcher 
			 | 
		
	
		
			
			| 
				390
			 | 
			
				391
			 | 
			
			
				                      sendDeviceEventWithName:streamEventCode 
			 | 
		
	
		
			
			| 
				391
			 | 
			
				392
			 | 
			
			
				                      body: @{ 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -393,11 +394,10 @@ void runOnMainQueueWithoutDeadlocking(void (^block)(void)) 
			 | 
		
	
		
			
			| 
				393
			 | 
			
				394
			 | 
			
			
				                              @"detail": asciiArray 
			 | 
		
	
		
			
			| 
				394
			 | 
			
				395
			 | 
			
			
				                             } 
			 | 
		
	
		
			
			| 
				395
			 | 
			
				396
			 | 
			
			
				                      ]; 
			 | 
		
	
		
			
			| 
				396
			 | 
			
				
			 | 
			
			
				-                    free(buf); 
			 | 
		
	
		
			
			| 
				397
			 | 
			
				
			 | 
			
			
				-                    bytePtr = nil; 
			 | 
		
	
		
			
			| 
				398
			 | 
			
				
			 | 
			
			
				-                    asciiArray = nil; 
			 | 
		
	
		
			
			| 
				399
			 | 
			
				
			 | 
			
			
				-                    buf = nil; 
			 | 
		
	
		
			
			| 
				400
			 | 
			
				
			 | 
			
			
				-                    chunkData = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				397
			 | 
			
			
				+//                    free(buf); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				398
			 | 
			
			
				+//                    asciiStr = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				399
			 | 
			
			
				+//                    buf = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				400
			 | 
			
			
				+//                    chunkData = nil; 
			 | 
		
	
		
			
			| 
				401
			 | 
			
				401
			 | 
			
			
				                     return; 
			 | 
		
	
		
			
			| 
				402
			 | 
			
				402
			 | 
			
			
				                 } 
			 | 
		
	
		
			
			| 
				403
			 | 
			
				403
			 | 
			
			
				                 // convert byte array to base64 data chunks 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -415,7 +415,7 @@ void runOnMainQueueWithoutDeadlocking(void (^block)(void)) 
			 | 
		
	
		
			
			| 
				415
			 | 
			
				415
			 | 
			
			
				                      ]; 
			 | 
		
	
		
			
			| 
				416
			 | 
			
				416
			 | 
			
			
				                     return; 
			 | 
		
	
		
			
			| 
				417
			 | 
			
				417
			 | 
			
			
				                 } 
			 | 
		
	
		
			
			| 
				418
			 | 
			
				
			 | 
			
			
				-                 
			 | 
		
	
		
			
			| 
				
			 | 
			
				418
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				419
			 | 
			
				419
			 | 
			
			
				                 [self.bridge.eventDispatcher 
			 | 
		
	
		
			
			| 
				420
			 | 
			
				420
			 | 
			
			
				                  sendDeviceEventWithName:streamEventCode 
			 | 
		
	
		
			
			| 
				421
			 | 
			
				421
			 | 
			
			
				                  body:@{ 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -423,8 +423,8 @@ void runOnMainQueueWithoutDeadlocking(void (^block)(void)) 
			 | 
		
	
		
			
			| 
				423
			 | 
			
				423
			 | 
			
			
				                         @"detail": encodedChunk 
			 | 
		
	
		
			
			| 
				424
			 | 
			
				424
			 | 
			
			
				                         } 
			 | 
		
	
		
			
			| 
				425
			 | 
			
				425
			 | 
			
			
				                  ]; 
			 | 
		
	
		
			
			| 
				426
			 | 
			
				
			 | 
			
			
				-                chunkData = nil; 
			 | 
		
	
		
			
			| 
				427
			 | 
			
				
			 | 
			
			
				-                free(buf); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				426
			 | 
			
			
				+//                chunkData = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				427
			 | 
			
			
				+//                free(buf); 
			 | 
		
	
		
			
			| 
				428
			 | 
			
				428
			 | 
			
			
				             } 
			 | 
		
	
		
			
			| 
				429
			 | 
			
				429
			 | 
			
			
				             // end of stream 
			 | 
		
	
		
			
			| 
				430
			 | 
			
				430
			 | 
			
			
				             else { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -435,12 +435,12 @@ void runOnMainQueueWithoutDeadlocking(void (^block)(void)) 
			 | 
		
	
		
			
			| 
				435
			 | 
			
				435
			 | 
			
			
				                         @"detail": @"" 
			 | 
		
	
		
			
			| 
				436
			 | 
			
				436
			 | 
			
			
				                         } 
			 | 
		
	
		
			
			| 
				437
			 | 
			
				437
			 | 
			
			
				                  ]; 
			 | 
		
	
		
			
			| 
				438
			 | 
			
				
			 | 
			
			
				-                chunkData = nil; 
			 | 
		
	
		
			
			| 
				439
			 | 
			
				
			 | 
			
			
				-                free(buf); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				438
			 | 
			
			
				+//                chunkData = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				439
			 | 
			
			
				+//                free(buf); 
			 | 
		
	
		
			
			| 
				440
			 | 
			
				440
			 | 
			
			
				             } 
			 | 
		
	
		
			
			| 
				441
			 | 
			
				441
			 | 
			
			
				             break; 
			 | 
		
	
		
			
			| 
				442
			 | 
			
				442
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				443
			 | 
			
				
			 | 
			
			
				-             
			 | 
		
	
		
			
			| 
				
			 | 
			
				443
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				444
			 | 
			
				444
			 | 
			
			
				             // stream error 
			 | 
		
	
		
			
			| 
				445
			 | 
			
				445
			 | 
			
			
				         case NSStreamEventErrorOccurred: 
			 | 
		
	
		
			
			| 
				446
			 | 
			
				446
			 | 
			
			
				         { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -453,10 +453,9 @@ void runOnMainQueueWithoutDeadlocking(void (^block)(void)) 
			 | 
		
	
		
			
			| 
				453
			 | 
			
				453
			 | 
			
			
				              ]; 
			 | 
		
	
		
			
			| 
				454
			 | 
			
				454
			 | 
			
			
				             break; 
			 | 
		
	
		
			
			| 
				455
			 | 
			
				455
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				456
			 | 
			
				
			 | 
			
			
				-             
			 | 
		
	
		
			
			| 
				
			 | 
			
				456
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				457
			 | 
			
				457
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				458
			 | 
			
				
			 | 
			
			
				-     
			 | 
		
	
		
			
			| 
				
			 | 
			
				458
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				459
			 | 
			
				459
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				460
			 | 
			
				460
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				461
			 | 
			
				461
			 | 
			
			
				 @end 
			 | 
		
	
		
			
			| 
				462
			 | 
			
				
			 | 
			
			
				- 
			 |