react-native-blob-util 0.21.1 → 0.21.3

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.
package/README.md CHANGED
@@ -28,7 +28,7 @@ react-native-blob-util version **0.10.16** and up is only compatible with react
28
28
 
29
29
  ## React Native New Architecture
30
30
  With React Native 0.68.0 the switch to enable the new aritechture was introduced.
31
- Starting with version 0.17.0 this library introduces support for the new architecture as well. Of course the old architecture will still be supproted.
31
+ Starting with version 0.17.0 this library introduces support for the new architecture as well. Of course the old architecture will still be supported.
32
32
  Further information about it and how to use it you can find here: https://reactnative.dev/docs/next/the-new-architecture/landing-page
33
33
 
34
34
  ## Android 10 & 11
@@ -631,13 +631,22 @@ This is a new feature added in `0.9.0` if you're going to open a file path using
631
631
 
632
632
  Download and install an APK programmatically
633
633
 
634
+ Note:
635
+ be sure to specify the path, do not use the default path, because the permission problem causes the installation to fail, parsing the package fails
636
+
637
+ default path: `/data/data/com.android.providers.downloads/cache/xxx.apk` // Will cause parsing of the package to fail,Unable to install APK
638
+
634
639
  ```js
635
640
 
636
641
  const android = ReactNativeBlobUtil.android
642
+ const dirs = ReactNativeBlobUtil.fs.dirs;
643
+ const apkUrl = "http://www.example.com/awesome.apk";
644
+ const fileName = url.substring(url.lastIndexOf('/') + 1);
637
645
 
638
646
  ReactNativeBlobUtil.config({
639
647
  addAndroidDownloads: {
640
648
  useDownloadManager: true,
649
+ path: `${dirs.DownloadDir}/${fileName}`, // <-- Must specify
641
650
  title: 'awesome.apk',
642
651
  description: 'An APK that will be installed',
643
652
  mime: 'application/vnd.android.package-archive',
@@ -11,6 +11,8 @@ import com.facebook.react.module.model.ReactModuleInfoProvider;
11
11
  import java.util.HashMap;
12
12
  import java.util.Map;
13
13
 
14
+ // trick autolinking till it is fixed on RN side
15
+ //public class ReactNativeBlobUtilPackage extends TurboReactPackage {
14
16
  public class ReactNativeBlobUtilPackage extends BaseReactPackage {
15
17
 
16
18
  @Nullable
@@ -238,10 +238,6 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
238
238
  @Override
239
239
  public void run() {
240
240
  Context appCtx = ReactNativeBlobUtilImpl.RCTContext.getApplicationContext();
241
- String t123 = String.valueOf(options.addAndroidDownloads.hasKey("storeLocal"));
242
- String t1234 = String.valueOf(options.addAndroidDownloads.getBoolean("storeLocal"));
243
- RNLog.w(ReactNativeBlobUtilImpl.RCTContext, t123);
244
- RNLog.w(ReactNativeBlobUtilImpl.RCTContext, t1234);
245
241
  // use download manager instead of default HTTP implementation
246
242
  if (options.addAndroidDownloads != null && options.addAndroidDownloads.hasKey("useDownloadManager")) {
247
243
 
@@ -279,7 +275,6 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
279
275
 
280
276
 
281
277
  if (options.addAndroidDownloads.hasKey("storeLocal") && options.addAndroidDownloads.getBoolean("storeLocal")) {
282
- RNLog.w(ReactNativeBlobUtilImpl.RCTContext, "a");
283
278
  String path = (String) ReactNativeBlobUtilFS.getSystemfolders(ReactNativeBlobUtilImpl.RCTContext).get("DownloadDir");
284
279
  path = path + UUID.randomUUID().toString();
285
280
 
@@ -72,10 +72,19 @@ public class ReactNativeBlobUtilFileResp extends ResponseBody {
72
72
 
73
73
  @Override
74
74
  public long contentLength() {
75
- if (originalBody.contentLength() > Integer.MAX_VALUE) {
75
+
76
+ /**
77
+ *
78
+ * Okio buffer issue in current version seems to be fixed in the latest versions
79
+ *
80
+ * limiting this was causing the download progress to stop at 2GB size but files still was downloading
81
+ *
82
+ */
83
+
84
+ // if (originalBody.contentLength() > Integer.MAX_VALUE) {
76
85
  // This is a workaround for a bug Okio buffer where it can't handle larger than int.
77
- return Integer.MAX_VALUE;
78
- }
86
+ // return Integer.MAX_VALUE;
87
+ // }
79
88
  return originalBody.contentLength();
80
89
  }
81
90
 
@@ -39,7 +39,7 @@ export default class ReactNativeBlobUtilSession {
39
39
 
40
40
  remove(path:string):ReactNativeBlobUtilSession {
41
41
  let list = sessions[this.name];
42
- for (let i of list) {
42
+ for (let i = 0; i < list.length; i++) {
43
43
  if (list[i] === path) {
44
44
  sessions[this.name].splice(i, 1);
45
45
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-blob-util",
3
- "version": "0.21.1",
3
+ "version": "0.21.3",
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": {