react-native-blob-util 0.19.3 → 0.19.5

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.
@@ -46,7 +46,10 @@ if (isNewArchitectureEnabled()) {
46
46
  android {
47
47
  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
48
48
  if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
49
- namespace "com.ronradtke.rnblobutil"
49
+ namespace "com.ReactNativeBlobUtil"
50
+ buildFeatures {
51
+ buildConfig true
52
+ }
50
53
  }
51
54
  compileSdkVersion safeExtGet('compileSdkVersion', 30)
52
55
  buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
@@ -1,5 +1,4 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.ReactNativeBlobUtil">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
2
 
4
3
  <!-- Required to download files from Google Play -->
5
4
  <uses-permission android:name="android.permission.INTERNET" />
@@ -36,4 +35,4 @@
36
35
  </provider>
37
36
  </application>
38
37
 
39
- </manifest>
38
+ </manifest>
@@ -638,6 +638,9 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
638
638
  */
639
639
  private void done(Response resp) {
640
640
  boolean isBlobResp = isBlobResponse(resp);
641
+ WritableMap respmap = getResponseInfo(resp,isBlobResp);
642
+ emitStateEvent(respmap.copy());
643
+
641
644
  emitStateEvent(getResponseInfo(resp, isBlobResp));
642
645
  switch (responseType) {
643
646
  case KeepInMemory:
@@ -656,7 +659,7 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
656
659
  ins.close();
657
660
  os.flush();
658
661
  os.close();
659
- invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, dest);
662
+ invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, dest, respmap.copy());
660
663
  }
661
664
  // response data directly pass to JS context as string.
662
665
  else {
@@ -678,11 +681,11 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
678
681
  invoke_callback("Error from file transformer:" + e.getLocalizedMessage(), null);
679
682
  return;
680
683
  }
681
- invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath);
684
+ invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath, respmap.copy());
682
685
  return;
683
686
  }
684
687
  if (responseFormat == ResponseFormat.BASE64) {
685
- invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_BASE64, android.util.Base64.encodeToString(b, Base64.NO_WRAP));
688
+ invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_BASE64, android.util.Base64.encodeToString(b, Base64.NO_WRAP), respmap.copy());
686
689
  return;
687
690
  }
688
691
  try {
@@ -699,9 +702,9 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
699
702
  catch (CharacterCodingException ignored) {
700
703
  if (responseFormat == ResponseFormat.UTF8) {
701
704
  String utf8 = new String(b);
702
- invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_UTF8, utf8);
705
+ invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_UTF8, utf8, respmap.copy());
703
706
  } else {
704
- invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_BASE64, android.util.Base64.encodeToString(b, Base64.NO_WRAP));
707
+ invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_BASE64, android.util.Base64.encodeToString(b, Base64.NO_WRAP), respmap.copy());
705
708
  }
706
709
  }
707
710
  }
@@ -746,16 +749,16 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
746
749
  }
747
750
 
748
751
  if (ReactNativeBlobUtilFileResp != null && !ReactNativeBlobUtilFileResp.isDownloadComplete()) {
749
- invoke_callback("Download interrupted.", null);
752
+ invoke_callback("Download interrupted.", null, respmap.copy());
750
753
  } else {
751
754
  this.destPath = this.destPath.replace("?append=true", "");
752
- invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath);
755
+ invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_PATH, this.destPath, respmap.copy());
753
756
  }
754
757
 
755
758
  break;
756
759
  default:
757
760
  try {
758
- invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_UTF8, new String(resp.body().bytes(), "UTF-8"));
761
+ invoke_callback(null, ReactNativeBlobUtilConst.RNFB_RESPONSE_UTF8, new String(resp.body().bytes(), "UTF-8"), respmap.copy());
759
762
  } catch (IOException e) {
760
763
  invoke_callback("ReactNativeBlobUtil failed to encode response data to UTF8 string.", null);
761
764
  }
package/fetch.js CHANGED
@@ -163,7 +163,7 @@ export function fetch(...args: any): Promise {
163
163
  let taskId = getUUID();
164
164
  let options = this || {};
165
165
  let subscription, subscriptionUpload, stateEvent, partEvent;
166
- let respInfo = {};
166
+ let respInfo = {'uninit': true};
167
167
  let [method, url, headers, body] = [...args];
168
168
 
169
169
  // # 241 normalize null or undefined headers, in case nil or null string
@@ -242,8 +242,9 @@ export function fetch(...args: any): Promise {
242
242
  * in JS context, and this parameter indicates which one
243
243
  * dose the response data presents.
244
244
  * @param data {string} Response data or its reference.
245
+ * @param responseInfo {Object.<>}
245
246
  */
246
- req(options, taskId, method, url, headers || {}, body, (err, rawType, data) => {
247
+ req(options, taskId, method, url, headers || {}, body, (err, rawType, data, responseInfo) => {
247
248
 
248
249
  // task done, remove event listeners
249
250
  subscription.remove();
@@ -269,6 +270,8 @@ export function fetch(...args: any): Promise {
269
270
  fs.session(options.session).add(data);
270
271
  }
271
272
  respInfo.rnfbEncode = rawType;
273
+ if ('uninit' in respInfo && respInfo.uninit) // event didn't fire yet so we override it here
274
+ respInfo = responseInfo;
272
275
  resolve(new FetchBlobResponse(taskId, respInfo, data));
273
276
  }
274
277
 
@@ -464,11 +464,16 @@ typedef NS_ENUM(NSUInteger, ResponseFormat) {
464
464
  }
465
465
  }
466
466
 
467
+ NSHTTPURLResponse *response = (NSHTTPURLResponse *) [task response];
467
468
 
468
469
  callback(@[
469
470
  errMsg ?: [NSNull null],
470
471
  rnfbRespType ?: @"",
471
- respStr ?: [NSNull null]
472
+ respStr ?: [NSNull null],
473
+ @{
474
+ @"status": [NSNumber numberWithInteger:[response statusCode]]
475
+ }
476
+ ]);
472
477
  ]);
473
478
 
474
479
  respData = nil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-blob-util",
3
- "version": "0.19.3",
3
+ "version": "0.19.5",
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": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "base-64": "0.1.0",
11
- "glob": "^7.2.3"
11
+ "glob": "^10.3.10"
12
12
  },
13
13
  "keywords": [
14
14
  "react-native",