react-native-blob-util 0.19.0 → 0.19.2

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.
Files changed (91) hide show
  1. package/.eslintrc.js +56 -56
  2. package/LICENSE +21 -21
  3. package/Migration.md +41 -41
  4. package/README.md +1071 -1071
  5. package/android/gradle.properties +1 -1
  6. package/android/proguard-rules.pro +17 -17
  7. package/android/src/main/AndroidManifest.xml +39 -40
  8. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilConfig.java +57 -57
  9. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilConst.java +20 -20
  10. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java +2 -2
  11. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFileTransformer.java +9 -9
  12. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilImpl.java +431 -431
  13. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilProgressConfig.java +39 -39
  14. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java +972 -968
  15. package/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilDefaultResp.java +98 -98
  16. package/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilFileResp.java +157 -157
  17. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/FileDescription.java +19 -19
  18. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/FileProvider.java +4 -4
  19. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/MimeType.java +70 -70
  20. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/PathResolver.java +223 -223
  21. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/Tls12SocketFactory.java +68 -68
  22. package/android/src/main/res/values/strings.xml +3 -3
  23. package/android/src/main/res/xml/provider_paths.xml +12 -12
  24. package/android/src/newarch/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java +1 -1
  25. package/android.js +58 -58
  26. package/class/ReactNativeBlobUtilCanceledFetchError.js +9 -9
  27. package/class/ReactNativeBlobUtilFile.js +5 -5
  28. package/class/ReactNativeBlobUtilReadStream.js +84 -84
  29. package/class/ReactNativeBlobUtilSession.js +68 -68
  30. package/class/ReactNativeBlobUtilWriteStream.js +50 -50
  31. package/class/StatefulPromise.js +7 -7
  32. package/codegenSpecs/NativeBlobUtils.js +86 -82
  33. package/components/Fetch.onPress.js +10 -10
  34. package/components/Fetch.when.js +15 -15
  35. package/fetch.js +344 -344
  36. package/fs.js +480 -480
  37. package/index.d.ts +871 -871
  38. package/index.js +64 -64
  39. package/index.js.flow +191 -191
  40. package/index.web.js +1 -1
  41. package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.h +55 -55
  42. package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm +993 -993
  43. package/ios/ReactNativeBlobUtil.xcodeproj/project.pbxproj +403 -403
  44. package/ios/ReactNativeBlobUtilConst.h +58 -58
  45. package/ios/ReactNativeBlobUtilConst.mm +47 -47
  46. package/ios/ReactNativeBlobUtilFS.h +108 -108
  47. package/ios/ReactNativeBlobUtilFS.mm +977 -977
  48. package/ios/ReactNativeBlobUtilFileTransformer.h +23 -23
  49. package/ios/ReactNativeBlobUtilFileTransformer.mm +20 -20
  50. package/ios/ReactNativeBlobUtilNetwork.h +49 -49
  51. package/ios/ReactNativeBlobUtilNetwork.mm +159 -159
  52. package/ios/ReactNativeBlobUtilProgress.h +32 -32
  53. package/ios/ReactNativeBlobUtilProgress.mm +57 -57
  54. package/ios/ReactNativeBlobUtilReqBuilder.h +37 -37
  55. package/ios/ReactNativeBlobUtilReqBuilder.mm +292 -292
  56. package/ios/ReactNativeBlobUtilRequest.h +48 -48
  57. package/ios/ReactNativeBlobUtilRequest.mm +535 -535
  58. package/ios.js +61 -61
  59. package/json-stream.js +42 -42
  60. package/lib/oboe-browser.js +2703 -2703
  61. package/mediacollection.js +36 -36
  62. package/package.json +55 -55
  63. package/polyfill/Blob.js +362 -362
  64. package/polyfill/Event.js +11 -11
  65. package/polyfill/EventTarget.js +78 -78
  66. package/polyfill/Fetch.js +219 -219
  67. package/polyfill/File.js +27 -27
  68. package/polyfill/FileReader.js +91 -91
  69. package/polyfill/ProgressEvent.js +32 -32
  70. package/polyfill/XMLHttpRequest.js +466 -466
  71. package/polyfill/XMLHttpRequestEventTarget.js +126 -126
  72. package/polyfill/index.js +11 -11
  73. package/react-native-blob-util.podspec +45 -45
  74. package/types.js +69 -69
  75. package/utils/log.js +40 -40
  76. package/utils/unicode.js +7 -7
  77. package/utils/uri.js +33 -33
  78. package/utils/uuid.js +4 -4
  79. package/windows/README.md +2 -2
  80. package/windows/ReactNativeBlobUtil/PropertySheet.props +15 -15
  81. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.cpp +1701 -1693
  82. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.def +3 -3
  83. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.h +379 -366
  84. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.vcxproj +181 -181
  85. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.vcxproj.filters +31 -31
  86. package/windows/ReactNativeBlobUtil/ReactPackageProvider.cpp +15 -15
  87. package/windows/ReactNativeBlobUtil/ReactPackageProvider.h +20 -20
  88. package/windows/ReactNativeBlobUtil/ReactPackageProvider.idl +9 -9
  89. package/windows/ReactNativeBlobUtil/packages.config +3 -3
  90. package/windows/ReactNativeBlobUtil/pch.cpp +1 -1
  91. package/windows/ReactNativeBlobUtil/pch.h +3 -3
@@ -1,2 +1,2 @@
1
- android.enableJetifier=true
1
+ android.enableJetifier=true
2
2
  android.useAndroidX=true
@@ -1,17 +1,17 @@
1
- # Add project specific ProGuard rules here.
2
- # By default, the flags in this file are appended to flags specified
3
- # in /Users/xeiyan/Library/Android/sdk/tools/proguard/proguard-android.txt
4
- # You can edit the include path and order by changing the proguardFiles
5
- # directive in build.gradle.
6
- #
7
- # For more details, see
8
- # http://developer.android.com/guide/developing/tools/proguard.html
9
-
10
- # Add any project specific keep options here:
11
-
12
- # If your project uses WebView with JS, uncomment the following
13
- # and specify the fully qualified class name to the JavaScript interface
14
- # class:
15
- #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16
- # public *;
17
- #}
1
+ # Add project specific ProGuard rules here.
2
+ # By default, the flags in this file are appended to flags specified
3
+ # in /Users/xeiyan/Library/Android/sdk/tools/proguard/proguard-android.txt
4
+ # You can edit the include path and order by changing the proguardFiles
5
+ # directive in build.gradle.
6
+ #
7
+ # For more details, see
8
+ # http://developer.android.com/guide/developing/tools/proguard.html
9
+
10
+ # Add any project specific keep options here:
11
+
12
+ # If your project uses WebView with JS, uncomment the following
13
+ # and specify the fully qualified class name to the JavaScript interface
14
+ # class:
15
+ #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16
+ # public *;
17
+ #}
@@ -1,40 +1,39 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.ReactNativeBlobUtil">
3
-
4
- <!-- Required to download files from Google Play -->
5
- <uses-permission android:name="android.permission.INTERNET" />
6
-
7
- <!-- Required to keep CPU alive while downloading files
8
- (NOT to keep screen awake) -->
9
- <uses-permission android:name="android.permission.WAKE_LOCK" />
10
-
11
- <!-- Required to poll the state of the network connection
12
- and respond to changes -->
13
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
14
-
15
- <!-- Required to check whether Wi-Fi is enabled -->
16
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
17
-
18
- <!-- Required to read and write the expansion files on shared storage -->
19
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
20
-
21
- <!-- Required to read and write the expansion files on shared storage for Android 11-->
22
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
23
-
24
- <!-- Required to to download files without a notification-->
25
- <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
26
-
27
- <application android:label="@string/app_name">
28
-
29
- <provider
30
- android:name="com.ReactNativeBlobUtil.Utils.FileProvider"
31
- android:authorities="${applicationId}.provider"
32
- android:exported="false"
33
- android:grantUriPermissions="true">
34
- <meta-data
35
- android:name="android.support.FILE_PROVIDER_PATHS"
36
- android:resource="@xml/provider_paths" />
37
- </provider>
38
- </application>
39
-
40
- </manifest>
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.ReactNativeBlobUtil">
3
+
4
+ <!-- Required to download files from Google Play -->
5
+ <uses-permission android:name="android.permission.INTERNET" />
6
+
7
+ <!-- Required to keep CPU alive while downloading files
8
+ (NOT to keep screen awake) -->
9
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
10
+
11
+ <!-- Required to poll the state of the network connection
12
+ and respond to changes -->
13
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
14
+
15
+ <!-- Required to check whether Wi-Fi is enabled -->
16
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
17
+
18
+ <!-- Required to read and write the expansion files on shared storage -->
19
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
20
+
21
+ <!-- Required to read and write the expansion files on shared storage for Android 11-->
22
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
23
+
24
+ <!-- Required to to download files without a notification-->
25
+ <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
26
+
27
+ <application>
28
+ <provider
29
+ android:name="com.ReactNativeBlobUtil.Utils.FileProvider"
30
+ android:authorities="${applicationId}.provider"
31
+ android:exported="false"
32
+ android:grantUriPermissions="true">
33
+ <meta-data
34
+ android:name="android.support.FILE_PROVIDER_PATHS"
35
+ android:resource="@xml/provider_paths" />
36
+ </provider>
37
+ </application>
38
+
39
+ </manifest>
@@ -1,57 +1,57 @@
1
- package com.ReactNativeBlobUtil;
2
-
3
- import com.facebook.react.bridge.ReadableArray;
4
- import com.facebook.react.bridge.ReadableMap;
5
-
6
- import java.util.Locale;
7
-
8
- class ReactNativeBlobUtilConfig {
9
-
10
- public Boolean fileCache;
11
- public Boolean transformFile;
12
- public String path;
13
- public String appendExt;
14
- public ReadableMap addAndroidDownloads;
15
- public Boolean trusty;
16
- public Boolean wifiOnly = false;
17
- public String key;
18
- public String mime;
19
- public Boolean auto;
20
- public Boolean overwrite = true;
21
- public long timeout = 60000;
22
- public Boolean increment = false;
23
- public Boolean followRedirect = true;
24
- public ReadableArray binaryContentTypes = null;
25
-
26
- ReactNativeBlobUtilConfig(ReadableMap options) {
27
- if (options == null)
28
- return;
29
- this.fileCache = options.hasKey("fileCache") && options.getBoolean("fileCache");
30
- this.transformFile = options.hasKey("transformFile") ? options.getBoolean("transformFile") : false;
31
- this.path = options.hasKey("path") ? options.getString("path") : null;
32
- this.appendExt = options.hasKey("appendExt") ? options.getString("appendExt") : "";
33
- this.trusty = options.hasKey("trusty") && options.getBoolean("trusty");
34
- this.wifiOnly = options.hasKey("wifiOnly") && options.getBoolean("wifiOnly");
35
- if (options.hasKey("addAndroidDownloads")) {
36
- this.addAndroidDownloads = options.getMap("addAndroidDownloads");
37
- }
38
- if (options.hasKey("binaryContentTypes"))
39
- this.binaryContentTypes = options.getArray("binaryContentTypes");
40
- if (this.path != null && path.toLowerCase(Locale.ROOT).contains("?append=true")) {
41
- this.overwrite = false;
42
- }
43
- if (options.hasKey("overwrite"))
44
- this.overwrite = options.getBoolean("overwrite");
45
- if (options.hasKey("followRedirect")) {
46
- this.followRedirect = options.getBoolean("followRedirect");
47
- }
48
- this.key = options.hasKey("key") ? options.getString("key") : null;
49
- this.mime = options.hasKey("contentType") ? options.getString("contentType") : null;
50
- this.increment = options.hasKey("increment") && options.getBoolean("increment");
51
- this.auto = options.hasKey("auto") && options.getBoolean("auto");
52
- if (options.hasKey("timeout")) {
53
- this.timeout = options.getInt("timeout");
54
- }
55
- }
56
-
57
- }
1
+ package com.ReactNativeBlobUtil;
2
+
3
+ import com.facebook.react.bridge.ReadableArray;
4
+ import com.facebook.react.bridge.ReadableMap;
5
+
6
+ import java.util.Locale;
7
+
8
+ class ReactNativeBlobUtilConfig {
9
+
10
+ public Boolean fileCache;
11
+ public Boolean transformFile;
12
+ public String path;
13
+ public String appendExt;
14
+ public ReadableMap addAndroidDownloads;
15
+ public Boolean trusty;
16
+ public Boolean wifiOnly = false;
17
+ public String key;
18
+ public String mime;
19
+ public Boolean auto;
20
+ public Boolean overwrite = true;
21
+ public long timeout = 60000;
22
+ public Boolean increment = false;
23
+ public Boolean followRedirect = true;
24
+ public ReadableArray binaryContentTypes = null;
25
+
26
+ ReactNativeBlobUtilConfig(ReadableMap options) {
27
+ if (options == null)
28
+ return;
29
+ this.fileCache = options.hasKey("fileCache") && options.getBoolean("fileCache");
30
+ this.transformFile = options.hasKey("transformFile") ? options.getBoolean("transformFile") : false;
31
+ this.path = options.hasKey("path") ? options.getString("path") : null;
32
+ this.appendExt = options.hasKey("appendExt") ? options.getString("appendExt") : "";
33
+ this.trusty = options.hasKey("trusty") && options.getBoolean("trusty");
34
+ this.wifiOnly = options.hasKey("wifiOnly") && options.getBoolean("wifiOnly");
35
+ if (options.hasKey("addAndroidDownloads")) {
36
+ this.addAndroidDownloads = options.getMap("addAndroidDownloads");
37
+ }
38
+ if (options.hasKey("binaryContentTypes"))
39
+ this.binaryContentTypes = options.getArray("binaryContentTypes");
40
+ if (this.path != null && path.toLowerCase(Locale.ROOT).contains("?append=true")) {
41
+ this.overwrite = false;
42
+ }
43
+ if (options.hasKey("overwrite"))
44
+ this.overwrite = options.getBoolean("overwrite");
45
+ if (options.hasKey("followRedirect")) {
46
+ this.followRedirect = options.getBoolean("followRedirect");
47
+ }
48
+ this.key = options.hasKey("key") ? options.getString("key") : null;
49
+ this.mime = options.hasKey("contentType") ? options.getString("contentType") : null;
50
+ this.increment = options.hasKey("increment") && options.getBoolean("increment");
51
+ this.auto = options.hasKey("auto") && options.getBoolean("auto");
52
+ if (options.hasKey("timeout")) {
53
+ this.timeout = options.getInt("timeout");
54
+ }
55
+ }
56
+
57
+ }
@@ -1,20 +1,20 @@
1
- package com.ReactNativeBlobUtil;
2
-
3
-
4
- public class ReactNativeBlobUtilConst {
5
- public static final String EVENT_UPLOAD_PROGRESS = "ReactNativeBlobUtilProgress-upload";
6
- public static final String EVENT_PROGRESS = "ReactNativeBlobUtilProgress";
7
- public static final String EVENT_HTTP_STATE = "ReactNativeBlobUtilState";
8
- public static final String EVENT_MESSAGE = "ReactNativeBlobUtilMessage";
9
- public static final String EVENT_FILESYSTEM = "ReactNativeBlobUtilFilesystem";
10
- public static final String FILE_PREFIX = "ReactNativeBlobUtil-file://";
11
- public static final String CONTENT_PREFIX = "ReactNativeBlobUtil-content://";
12
- public static final String FILE_PREFIX_BUNDLE_ASSET = "bundle-assets://";
13
- public static final String FILE_PREFIX_CONTENT = "content://";
14
- public static final String DATA_ENCODE_URI = "uri";
15
- public static final String RNFB_RESPONSE_BASE64 = "base64";
16
- public static final String RNFB_RESPONSE_UTF8 = "utf8";
17
- public static final String RNFB_RESPONSE_PATH = "path";
18
- public static final Integer GET_CONTENT_INTENT = 99900;
19
-
20
- }
1
+ package com.ReactNativeBlobUtil;
2
+
3
+
4
+ public class ReactNativeBlobUtilConst {
5
+ public static final String EVENT_UPLOAD_PROGRESS = "ReactNativeBlobUtilProgress-upload";
6
+ public static final String EVENT_PROGRESS = "ReactNativeBlobUtilProgress";
7
+ public static final String EVENT_HTTP_STATE = "ReactNativeBlobUtilState";
8
+ public static final String EVENT_MESSAGE = "ReactNativeBlobUtilMessage";
9
+ public static final String EVENT_FILESYSTEM = "ReactNativeBlobUtilFilesystem";
10
+ public static final String FILE_PREFIX = "ReactNativeBlobUtil-file://";
11
+ public static final String CONTENT_PREFIX = "ReactNativeBlobUtil-content://";
12
+ public static final String FILE_PREFIX_BUNDLE_ASSET = "bundle-assets://";
13
+ public static final String FILE_PREFIX_CONTENT = "content://";
14
+ public static final String DATA_ENCODE_URI = "uri";
15
+ public static final String RNFB_RESPONSE_BASE64 = "base64";
16
+ public static final String RNFB_RESPONSE_UTF8 = "utf8";
17
+ public static final String RNFB_RESPONSE_PATH = "path";
18
+ public static final Integer GET_CONTENT_INTENT = 99900;
19
+
20
+ }
@@ -257,9 +257,9 @@ class ReactNativeBlobUtilFS {
257
257
  if (resolved != null && resolved.startsWith(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET)) {
258
258
  String assetName = path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, "");
259
259
  // This fails should an asset file be >2GB
260
- length = (int) ReactNativeBlobUtilImpl.RCTContext.getAssets().openFd(assetName).getLength();
261
- bytes = new byte[length];
262
260
  InputStream in = ReactNativeBlobUtilImpl.RCTContext.getAssets().open(assetName);
261
+ length = in.available();
262
+ bytes = new byte[length];
263
263
  bytesRead = in.read(bytes, 0, length);
264
264
  in.close();
265
265
  }
@@ -1,10 +1,10 @@
1
- package com.ReactNativeBlobUtil;
2
-
3
- public class ReactNativeBlobUtilFileTransformer {
4
- public interface FileTransformer {
5
- public byte[] onWriteFile(byte[] data);
6
- public byte[] onReadFile(byte[] data);
7
- }
8
-
9
- public static ReactNativeBlobUtilFileTransformer.FileTransformer sharedFileTransformer;
1
+ package com.ReactNativeBlobUtil;
2
+
3
+ public class ReactNativeBlobUtilFileTransformer {
4
+ public interface FileTransformer {
5
+ public byte[] onWriteFile(byte[] data);
6
+ public byte[] onReadFile(byte[] data);
7
+ }
8
+
9
+ public static ReactNativeBlobUtilFileTransformer.FileTransformer sharedFileTransformer;
10
10
  }