react-native-blob-util 0.23.1 → 0.24.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.
- package/.eslintrc.json +96 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java +33 -16
- package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm +1 -1
- package/ios/ReactNativeBlobUtilFS.h +1 -1
- package/ios/ReactNativeBlobUtilFS.mm +2 -2
- package/package.json +67 -65
- package/.eslintrc.js +0 -56
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"extends": [
|
|
4
|
+
"@react-native"
|
|
5
|
+
//"plugin:import/recommended"
|
|
6
|
+
],
|
|
7
|
+
"rules": {
|
|
8
|
+
"prettier/prettier": 0,
|
|
9
|
+
"eqeqeq": 2,
|
|
10
|
+
"comma-dangle": 0,
|
|
11
|
+
"curly": 0,
|
|
12
|
+
"no-console": 1,
|
|
13
|
+
"no-debugger": 1,
|
|
14
|
+
"no-extra-semi": 2,
|
|
15
|
+
"no-extra-parens": 1,
|
|
16
|
+
"no-extra-boolean-cast": 1,
|
|
17
|
+
"no-cond-assign": 2,
|
|
18
|
+
"no-irregular-whitespace": 2,
|
|
19
|
+
"no-undef": 0,
|
|
20
|
+
"no-unused-vars": 0,
|
|
21
|
+
"semi": 2,
|
|
22
|
+
"semi-spacing": 2,
|
|
23
|
+
"valid-jsdoc": 0,
|
|
24
|
+
"radix": 0,
|
|
25
|
+
"no-extend-native": 0,
|
|
26
|
+
"react/display-name": 2,
|
|
27
|
+
"react/forbid-prop-types": 1,
|
|
28
|
+
"react/jsx-boolean-value": 1,
|
|
29
|
+
"react/jsx-closing-bracket-location": 1,
|
|
30
|
+
"react/jsx-curly-spacing": 1,
|
|
31
|
+
"react/jsx-indent-props": 0,
|
|
32
|
+
"react/jsx-max-props-per-line": 0,
|
|
33
|
+
"react/jsx-no-duplicate-props": 1,
|
|
34
|
+
"react/jsx-no-literals": 0,
|
|
35
|
+
"react/jsx-no-undef": 1,
|
|
36
|
+
"react/jsx-sort-props": 0,
|
|
37
|
+
"react/jsx-uses-react": 1,
|
|
38
|
+
"react/jsx-uses-vars": 1,
|
|
39
|
+
"react/jsx-wrap-multilines": 0,
|
|
40
|
+
"react/no-danger": 1,
|
|
41
|
+
"react/no-did-mount-set-state": 1,
|
|
42
|
+
"react/no-did-update-set-state": 1,
|
|
43
|
+
"react/no-direct-mutation-state": 1,
|
|
44
|
+
"react/no-multi-comp": 1,
|
|
45
|
+
"react/no-set-state": 0,
|
|
46
|
+
"react/no-unknown-property": 1,
|
|
47
|
+
"react/prop-types": 0,
|
|
48
|
+
"react/react-in-jsx-scope": 0,
|
|
49
|
+
"react/self-closing-comp": 1,
|
|
50
|
+
"react/sort-comp": 1,
|
|
51
|
+
"import/no-unresolved": 0,
|
|
52
|
+
"import/no-default-export": 1,
|
|
53
|
+
"import/order": [
|
|
54
|
+
1,
|
|
55
|
+
{
|
|
56
|
+
"groups": [
|
|
57
|
+
"external",
|
|
58
|
+
"internal",
|
|
59
|
+
"index",
|
|
60
|
+
"sibling",
|
|
61
|
+
"parent",
|
|
62
|
+
"builtin",
|
|
63
|
+
"object",
|
|
64
|
+
"type"
|
|
65
|
+
],
|
|
66
|
+
"alphabetize": {
|
|
67
|
+
"order": "asc",
|
|
68
|
+
/* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */
|
|
69
|
+
"caseInsensitive": true
|
|
70
|
+
/* ignore case. Options: [true, false] */
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"quotes": [
|
|
75
|
+
"warn",
|
|
76
|
+
"single",
|
|
77
|
+
{
|
|
78
|
+
"allowTemplateLiterals": true
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"overrides": [
|
|
83
|
+
{
|
|
84
|
+
"files": [
|
|
85
|
+
"*.ts",
|
|
86
|
+
"*.tsx"
|
|
87
|
+
],
|
|
88
|
+
"rules": {
|
|
89
|
+
"no-dupe-class-members": "off"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"plugins": [
|
|
94
|
+
"import"
|
|
95
|
+
]
|
|
96
|
+
}
|
package/android/build.gradle
CHANGED
|
@@ -88,7 +88,7 @@ android {
|
|
|
88
88
|
|
|
89
89
|
dependencies {
|
|
90
90
|
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
|
|
91
|
-
implementation 'org.apache.commons:commons-lang3:
|
|
91
|
+
implementation 'org.apache.commons:commons-lang3:20:0'
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
afterEvaluate { project ->
|
|
@@ -12,8 +12,9 @@ import android.net.NetworkCapabilities;
|
|
|
12
12
|
import android.net.NetworkInfo;
|
|
13
13
|
import android.net.Uri;
|
|
14
14
|
import android.net.LinkProperties;
|
|
15
|
-
import android.net.
|
|
16
|
-
import java.net.Inet4Address;
|
|
15
|
+
import android.net.RouteInfo;
|
|
16
|
+
import java.net.Inet4Address;
|
|
17
|
+
import java.net.InetAddress;
|
|
17
18
|
import android.os.Build;
|
|
18
19
|
import android.os.Bundle;
|
|
19
20
|
import android.os.Environment;
|
|
@@ -44,6 +45,7 @@ import java.io.FileOutputStream;
|
|
|
44
45
|
import java.io.IOException;
|
|
45
46
|
import java.io.InputStream;
|
|
46
47
|
import java.net.MalformedURLException;
|
|
48
|
+
import java.net.UnknownHostException;
|
|
47
49
|
import java.net.Proxy;
|
|
48
50
|
import java.net.SocketException;
|
|
49
51
|
import java.net.SocketTimeoutException;
|
|
@@ -391,10 +393,22 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
|
|
|
391
393
|
|
|
392
394
|
// wifi only, need ACCESS_NETWORK_STATE permission
|
|
393
395
|
// and API level >= 21
|
|
394
|
-
|
|
396
|
+
final String targetHostIp = this.options.targetHostIp;
|
|
397
|
+
boolean targetHostIpAvailable = (targetHostIp != null && !targetHostIp.isEmpty());
|
|
398
|
+
|
|
395
399
|
if (this.options.wifiOnly) {
|
|
396
400
|
boolean found = false;
|
|
397
401
|
|
|
402
|
+
// convert targetHostIp from String into InetAddress
|
|
403
|
+
InetAddress targetHostAddr = null;
|
|
404
|
+
if (targetHostIpAvailable) {
|
|
405
|
+
try {
|
|
406
|
+
targetHostAddr = InetAddress.getByName(targetHostIp);
|
|
407
|
+
} catch (UnknownHostException e) {
|
|
408
|
+
targetHostAddr = null; // skip
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
398
412
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
399
413
|
ConnectivityManager connectivityManager = (ConnectivityManager) ReactNativeBlobUtilImpl.RCTContext.getSystemService(ReactNativeBlobUtilImpl.RCTContext.CONNECTIVITY_SERVICE);
|
|
400
414
|
Network[] networks = connectivityManager.getAllNetworks();
|
|
@@ -408,9 +422,7 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
|
|
|
408
422
|
|
|
409
423
|
// if targetHostIpAvailable does not match, fallback to any wifi
|
|
410
424
|
if (targetHostIpAvailable) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
if (networkMatchesTargetIp(connectivityManager, network, targetHostIp)) {
|
|
425
|
+
if (networkMatchesTargetIp(connectivityManager, network, targetHostIp, targetHostAddr)) {
|
|
414
426
|
clientBuilder.proxy(Proxy.NO_PROXY);
|
|
415
427
|
clientBuilder.socketFactory(network.getSocketFactory());
|
|
416
428
|
found = true;
|
|
@@ -1048,28 +1060,33 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
|
|
|
1048
1060
|
/**
|
|
1049
1061
|
* Check if a network matches the target host IP address
|
|
1050
1062
|
*/
|
|
1051
|
-
private boolean networkMatchesTargetIp(ConnectivityManager cm, Network network, String targetHostIp) {
|
|
1063
|
+
private boolean networkMatchesTargetIp(ConnectivityManager cm, Network network, String targetHostIp, InetAddress targetHostAddr) {
|
|
1052
1064
|
LinkProperties lp = cm.getLinkProperties(network);
|
|
1053
1065
|
if (lp == null) return false;
|
|
1054
1066
|
|
|
1055
1067
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
1056
|
-
// For Android
|
|
1068
|
+
// For Android 11 and above, use DHCP server address
|
|
1057
1069
|
Inet4Address dhcpServer = lp.getDhcpServerAddress();
|
|
1058
1070
|
if (dhcpServer != null && dhcpServer.getHostAddress().equals(targetHostIp)) {
|
|
1059
1071
|
return true;
|
|
1060
1072
|
}
|
|
1061
1073
|
}
|
|
1062
|
-
|
|
1063
|
-
//
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1074
|
+
|
|
1075
|
+
// For older versions or Android 11+ if DHCP does not match, check routing table
|
|
1076
|
+
if (targetHostAddr != null) {
|
|
1077
|
+
List<RouteInfo> routes = lp.getRoutes();
|
|
1078
|
+
if (routes != null) {
|
|
1079
|
+
for (RouteInfo route : routes) {
|
|
1080
|
+
if (route.isDefaultRoute()) {
|
|
1081
|
+
continue;
|
|
1082
|
+
}
|
|
1083
|
+
if (route.matches(targetHostAddr)) {
|
|
1084
|
+
return true;
|
|
1085
|
+
}
|
|
1069
1086
|
}
|
|
1070
1087
|
}
|
|
1071
1088
|
}
|
|
1072
|
-
|
|
1089
|
+
|
|
1073
1090
|
return false;
|
|
1074
1091
|
}
|
|
1075
1092
|
}
|
|
@@ -728,7 +728,7 @@ RCT_EXPORT_METHOD(hash:(NSString *)path
|
|
|
728
728
|
}
|
|
729
729
|
|
|
730
730
|
#pragma mark - fs.readStream
|
|
731
|
-
RCT_EXPORT_METHOD(readStream:(NSString *)path encoding:(NSString *)encoding bufferSize:(
|
|
731
|
+
RCT_EXPORT_METHOD(readStream:(NSString *)path encoding:(NSString *)encoding bufferSize:(double)bufferSize tick:(double)tick streamId:(NSString *)streamId)
|
|
732
732
|
{
|
|
733
733
|
if(bufferSize == 0) {
|
|
734
734
|
if([[encoding lowercaseString] isEqualToString:@"base64"])
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
rejecter:(RCTPromiseRejectBlock)reject;
|
|
84
84
|
//+ (void) writeFileFromFile:(NSString *)src toFile:(NSString *)dest append:(BOOL)append;
|
|
85
85
|
+ (void) writeAssetToPath:(PHAsset * )asset dest:(NSString *)dest;
|
|
86
|
-
+ (void) readStream:(NSString *)uri encoding:(NSString * )encoding bufferSize:(
|
|
86
|
+
+ (void) readStream:(NSString *)uri encoding:(NSString * )encoding bufferSize:(double)bufferSize tick:(double)tick streamId:(NSString *)streamId baseModule:(ReactNativeBlobUtil *)baseModule;
|
|
87
87
|
+ (void) df:(RCTResponseSenderBlock)callback;
|
|
88
88
|
|
|
89
89
|
// constructor
|
|
@@ -149,8 +149,8 @@ NSMutableDictionary *fileStreams = nil;
|
|
|
149
149
|
|
|
150
150
|
+ (void) readStream:(NSString *)uri
|
|
151
151
|
encoding:(NSString * )encoding
|
|
152
|
-
bufferSize:(
|
|
153
|
-
tick:(
|
|
152
|
+
bufferSize:(double)bufferSize
|
|
153
|
+
tick:(double)tick
|
|
154
154
|
streamId:(NSString *)streamId
|
|
155
155
|
baseModule:(ReactNativeBlobUtil*)baseModule
|
|
156
156
|
{
|
package/package.json
CHANGED
|
@@ -1,68 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
2
|
+
"name" : "react-native-blob-util",
|
|
3
|
+
"version" : "0.24.2",
|
|
4
|
+
"description" : "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
|
|
5
|
+
"main" : "index",
|
|
6
|
+
"scripts" : {
|
|
7
|
+
"test" : "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"dependencies" : {
|
|
10
|
+
"base-64" : "0.1.0",
|
|
11
|
+
"glob" : "13.0.0"
|
|
12
|
+
},
|
|
13
|
+
"keywords" : [
|
|
14
|
+
"react-native",
|
|
15
|
+
"fetch",
|
|
16
|
+
"blob",
|
|
17
|
+
"fs",
|
|
18
|
+
"upload",
|
|
19
|
+
"file",
|
|
20
|
+
"download",
|
|
21
|
+
"filestream",
|
|
22
|
+
"image header"
|
|
23
|
+
],
|
|
24
|
+
"repository" : {
|
|
25
|
+
"url" : "https://github.com/RonRadtke/react-native-blob-util"
|
|
26
|
+
},
|
|
27
|
+
"author" : {
|
|
28
|
+
"name" : "RonRadtke",
|
|
29
|
+
"username" : "RonRadtke"
|
|
30
|
+
},
|
|
31
|
+
"license" : "MIT",
|
|
32
|
+
"contributors" : [
|
|
33
|
+
"Traviskn <>",
|
|
34
|
+
"Ben <benhsieh@catchplay.com>",
|
|
35
|
+
"wkh237 <xeiyan@gmail.com>"
|
|
36
|
+
],
|
|
37
|
+
"devDependencies" : {
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
|
39
|
+
"@typescript-eslint/parser": "^8.46.4",
|
|
40
|
+
"eslint": "^8.57.1",
|
|
41
|
+
"eslint-plugin-ft-flow" : "^3.0.11",
|
|
42
|
+
"eslint-plugin-import" : "^2.32.0",
|
|
43
|
+
"eslint-plugin-react" : "^7.37.5",
|
|
44
|
+
"eslint-plugin-react-native" : "^5.0.0",
|
|
45
|
+
"react" : "19.0.0",
|
|
46
|
+
"react-native" : "0.78.2",
|
|
47
|
+
"react-native-windows" : "0.78.2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies" : {
|
|
50
|
+
"react" : "*",
|
|
51
|
+
"react-native" : "*"
|
|
52
|
+
},
|
|
53
|
+
"codegenConfig" : {
|
|
54
|
+
"name" : "ReactNativeBlobUtilSpec",
|
|
55
|
+
"type" : "modules",
|
|
56
|
+
"jsSrcsDir" : "codegenSpecs",
|
|
57
|
+
"windows" : {
|
|
58
|
+
"namespace" : "ReactNativeBlobUtilCodegen",
|
|
59
|
+
"outputDirectory" : "windows/ReactNativeBlobUtil/codegen",
|
|
60
|
+
"separateDataTypes" : true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"react-native-windows" : {
|
|
64
|
+
"init-windows" : {
|
|
65
|
+
"name" : "ReactNativeBlobUtil",
|
|
66
|
+
"namespace" : "ReactNativeBlobUtil",
|
|
67
|
+
"template" : "cpp-lib"
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
|
-
},
|
|
61
|
-
"react-native-windows": {
|
|
62
|
-
"init-windows": {
|
|
63
|
-
"name": "ReactNativeBlobUtil",
|
|
64
|
-
"namespace": "ReactNativeBlobUtil",
|
|
65
|
-
"template": "cpp-lib"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
70
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
extends: '@react-native-community',
|
|
4
|
-
rules: {
|
|
5
|
-
'prettier/prettier': 0,
|
|
6
|
-
"eqeqeq": 2,
|
|
7
|
-
"comma-dangle": 0,
|
|
8
|
-
curly: 0,
|
|
9
|
-
"no-console": 1,
|
|
10
|
-
"no-debugger": 1,
|
|
11
|
-
"no-extra-semi": 2,
|
|
12
|
-
"no-extra-parens": 1,
|
|
13
|
-
"no-extra-boolean-cast": 1,
|
|
14
|
-
"no-cond-assign": 2,
|
|
15
|
-
"no-irregular-whitespace": 2,
|
|
16
|
-
"no-undef": 0,
|
|
17
|
-
"no-unused-vars": 0,
|
|
18
|
-
"semi": 2,
|
|
19
|
-
"semi-spacing": 2,
|
|
20
|
-
"valid-jsdoc": [
|
|
21
|
-
1,
|
|
22
|
-
{
|
|
23
|
-
"requireReturn": false,
|
|
24
|
-
"requireParamDescription": false,
|
|
25
|
-
"requireReturnDescription": false
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"radix": 0,
|
|
29
|
-
|
|
30
|
-
"react/display-name": 2,
|
|
31
|
-
"react/forbid-prop-types": 1,
|
|
32
|
-
"react/jsx-boolean-value": 1,
|
|
33
|
-
"react/jsx-closing-bracket-location": 1,
|
|
34
|
-
"react/jsx-curly-spacing": 1,
|
|
35
|
-
"react/jsx-indent-props": 0,
|
|
36
|
-
"react/jsx-max-props-per-line": 0,
|
|
37
|
-
"react/jsx-no-duplicate-props": 1,
|
|
38
|
-
"react/jsx-no-literals": 0,
|
|
39
|
-
"react/jsx-no-undef": 1,
|
|
40
|
-
"react/jsx-sort-props": 0,
|
|
41
|
-
"react/jsx-uses-react": 1,
|
|
42
|
-
"react/jsx-uses-vars": 1,
|
|
43
|
-
"react/jsx-wrap-multilines": 1,
|
|
44
|
-
"react/no-danger": 1,
|
|
45
|
-
"react/no-did-mount-set-state": 1,
|
|
46
|
-
"react/no-did-update-set-state": 1,
|
|
47
|
-
"react/no-direct-mutation-state": 1,
|
|
48
|
-
"react/no-multi-comp": 1,
|
|
49
|
-
"react/no-set-state": 0,
|
|
50
|
-
"react/no-unknown-property": 1,
|
|
51
|
-
"react/prop-types": 0,
|
|
52
|
-
"react/react-in-jsx-scope": 0,
|
|
53
|
-
"react/self-closing-comp": 1,
|
|
54
|
-
"react/sort-comp": 1,
|
|
55
|
-
},
|
|
56
|
-
};
|