react-native-blob-util 0.19.6 → 0.19.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -678,7 +678,7 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
678
678
  try (FileOutputStream fos = new FileOutputStream(file)) {
679
679
  fos.write(ReactNativeBlobUtilFileTransformer.sharedFileTransformer.onWriteFile(b));
680
680
  } catch (Exception e) {
681
- invoke_callback("Error from file transformer:" + e.getLocalizedMessage(), null);
681
+ invoke_callback("Error from file transformer:" + e.getLocalizedMessage(), respmap.copy());
682
682
  return;
683
683
  }
684
684
  invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath, respmap.copy());
@@ -709,7 +709,7 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
709
709
  }
710
710
  }
711
711
  } catch (IOException e) {
712
- invoke_callback("ReactNativeBlobUtil failed to encode response data to BASE64 string.", null);
712
+ invoke_callback("ReactNativeBlobUtil failed to encode response data to BASE64 string.", respmap.copy());
713
713
  }
714
714
  break;
715
715
  case FileStorage:
@@ -741,15 +741,15 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
741
741
  } catch (IOException exception) {
742
742
  exception.printStackTrace();
743
743
  }
744
- invoke_callback("Unexpected FileStorage response file: " + responseBodyString, null);
744
+ invoke_callback("Unexpected FileStorage response file: " + responseBodyString, respmap.copy());
745
745
  } else {
746
- invoke_callback("Unexpected FileStorage response with no file.", null);
746
+ invoke_callback("Unexpected FileStorage response with no file.", respmap.copy());
747
747
  }
748
748
  return;
749
749
  }
750
750
 
751
751
  if (ReactNativeBlobUtilFileResp != null && !ReactNativeBlobUtilFileResp.isDownloadComplete()) {
752
- invoke_callback("Download interrupted.", null, respmap.copy());
752
+ invoke_callback("Download interrupted.", respmap.copy());
753
753
  } else {
754
754
  this.destPath = this.destPath.replace("?append=true", "");
755
755
  invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath, respmap.copy());
@@ -760,7 +760,7 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
760
760
  try {
761
761
  invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_UTF8, new String(resp.body().bytes(), "UTF-8"), respmap.copy());
762
762
  } catch (IOException e) {
763
- invoke_callback("ReactNativeBlobUtil failed to encode response data to UTF8 string.", null);
763
+ invoke_callback("ReactNativeBlobUtil failed to encode response data to UTF8 string.", respmap.copy());
764
764
  }
765
765
  break;
766
766
  }
package/fetch.js CHANGED
@@ -260,6 +260,8 @@ export function fetch(...args: any): Promise {
260
260
  promise.cancel = () => {
261
261
  };
262
262
 
263
+ if(!responseInfo) responseInfo = {}; // should not be null / undefined
264
+
263
265
  if (err)
264
266
  reject(new Error(err, respInfo));
265
267
  else {
@@ -269,9 +271,10 @@ export function fetch(...args: any): Promise {
269
271
  if (options.session)
270
272
  fs.session(options.session).add(data);
271
273
  }
272
- respInfo.rnfbEncode = rawType;
273
274
  if ('uninit' in respInfo && respInfo.uninit) // event didn't fire yet so we override it here
274
275
  respInfo = responseInfo;
276
+
277
+ respInfo.rnfbEncode = rawType;
275
278
  resolve(new FetchBlobResponse(taskId, respInfo, data));
276
279
  }
277
280
 
@@ -788,7 +788,7 @@ RCT_EXPORT_METHOD(presentOptionsMenu:(NSString*)uri scheme:(NSString *)scheme re
788
788
  resolve:(RCTPromiseResolveBlock)resolve
789
789
  reject:(RCTPromiseRejectBlock)reject
790
790
  {
791
- NSString * utf8uri = [uri stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
791
+ NSString * utf8uri = [uri stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
792
792
  NSURL * url = [[NSURL alloc] initWithString:utf8uri];
793
793
  // NSURL * url = [[NSURL alloc] initWithString:uri];
794
794
  documentController = [UIDocumentInteractionController interactionControllerWithURL:url];
@@ -818,7 +818,7 @@ RCT_EXPORT_METHOD(presentOpenInMenu:(NSString*)uri scheme:(NSString *)scheme res
818
818
  resolve:(RCTPromiseResolveBlock)resolve
819
819
  reject:(RCTPromiseRejectBlock)reject
820
820
  {
821
- NSString * utf8uri = [uri stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
821
+ NSString * utf8uri = [uri stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
822
822
  NSURL * url = [[NSURL alloc] initWithString:utf8uri];
823
823
  documentController = [UIDocumentInteractionController interactionControllerWithURL:url];
824
824
  UIViewController *rootCtrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
@@ -848,7 +848,7 @@ RCT_EXPORT_METHOD(presentPreview:(NSString*)uri scheme:(NSString *)scheme resolv
848
848
  resolve:(RCTPromiseResolveBlock)resolve
849
849
  reject:(RCTPromiseRejectBlock)reject
850
850
  {
851
- NSString * utf8uri = [uri stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
851
+ NSString * utf8uri = [uri stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
852
852
  NSURL * url = [[NSURL alloc] initWithString:utf8uri];
853
853
  // NSURL * url = [[NSURL alloc] initWithString:uri];
854
854
  documentController = [UIDocumentInteractionController interactionControllerWithURL:url];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-blob-util",
3
- "version": "0.19.6",
3
+ "version": "0.19.8",
4
4
  "description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
5
5
  "main": "index",
6
6
  "scripts": {