react-native-blob-util 0.16.4 → 0.17.0
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.js +29 -3
- package/Migration.md +41 -0
- package/README.md +13 -6
- package/android/build.gradle +19 -1
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilBody.java +6 -6
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java +12 -8
- package/android/src/main/java/com/ReactNativeBlobUtil/{ReactNativeBlobUtil.java → ReactNativeBlobUtilImpl.java} +19 -78
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilMediaCollection.java +5 -5
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilPackage.java +31 -21
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java +22 -21
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilStream.java +6 -6
- package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilUtils.java +2 -2
- package/android/src/newarch/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java +281 -0
- package/android/src/oldarch/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java +242 -0
- package/android.js +2 -3
- package/class/ReactNativeBlobUtilFile.js +1 -13
- package/class/ReactNativeBlobUtilReadStream.js +1 -2
- package/class/ReactNativeBlobUtilSession.js +1 -2
- package/class/ReactNativeBlobUtilWriteStream.js +1 -3
- package/codegenSpecs/NativeBlobUtils.js +77 -0
- package/fetch.js +2 -2
- package/fs.js +15 -22
- package/index.js +2 -2
- package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.h +10 -1
- package/ios/ReactNativeBlobUtil/{ReactNativeBlobUtil.m → ReactNativeBlobUtil.mm} +334 -41
- package/ios/{ReactNativeBlobUtilConst.m → ReactNativeBlobUtilConst.mm} +0 -0
- package/ios/ReactNativeBlobUtilFS.h +5 -5
- package/ios/{ReactNativeBlobUtilFS.m → ReactNativeBlobUtilFS.mm} +32 -26
- package/ios/{ReactNativeBlobUtilFileTransformer.m → ReactNativeBlobUtilFileTransformer.mm} +0 -0
- package/ios/ReactNativeBlobUtilNetwork.h +2 -2
- package/ios/{ReactNativeBlobUtilNetwork.m → ReactNativeBlobUtilNetwork.mm} +15 -17
- package/ios/{ReactNativeBlobUtilProgress.m → ReactNativeBlobUtilProgress.mm} +4 -4
- package/ios/{ReactNativeBlobUtilReqBuilder.m → ReactNativeBlobUtilReqBuilder.mm} +4 -4
- package/ios/ReactNativeBlobUtilRequest.h +4 -2
- package/ios/{ReactNativeBlobUtilRequest.m → ReactNativeBlobUtilRequest.mm} +16 -11
- package/ios.js +2 -3
- package/mediacollection.js +2 -4
- package/package.json +6 -1
- package/react-native-blob-util.podspec +21 -1
- package/examples/ReactNativeBlobUtil/.buckconfig +0 -6
- package/examples/ReactNativeBlobUtil/.eslintrc.js +0 -4
- package/examples/ReactNativeBlobUtil/.prettierrc.js +0 -6
- package/examples/ReactNativeBlobUtil/App.js +0 -698
- package/examples/ReactNativeBlobUtil/index.js +0 -9
- package/examples/ReactNativeBlobUtil/metro.config.js +0 -27
- package/examples/ReactNativeBlobUtil/package.json +0 -31
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.cpp +0 -80
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.h +0 -20
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.idl +0 -3
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.xaml +0 -10
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/LockScreenLogo.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/SplashScreen.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Square150x150Logo.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Square44x44Logo.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Square44x44Logo.targetsize-24_altform-unplated.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/StoreLogo.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Wide310x150Logo.scale-200.png +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/AutolinkedNativeModules.g.cpp +0 -18
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/AutolinkedNativeModules.g.h +0 -10
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/AutolinkedNativeModules.g.targets +0 -11
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.cpp +0 -24
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.h +0 -21
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.idl +0 -8
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.xaml +0 -16
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Package.appxmanifest +0 -50
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/PropertySheet.props +0 -16
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactNativeBlobUtilWin.vcxproj +0 -196
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactNativeBlobUtilWin.vcxproj.filters +0 -65
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactNativeBlobUtilWin_TemporaryKey.pfx +0 -0
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactPackageProvider.cpp +0 -18
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactPackageProvider.h +0 -15
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/packages.config +0 -5
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/pch.cpp +0 -1
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/pch.h +0 -26
- package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin.sln +0 -207
package/.eslintrc.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root: true,
|
|
3
|
+
extends: '@react-native-community',
|
|
3
4
|
rules: {
|
|
4
5
|
'prettier/prettier': 0,
|
|
5
6
|
"eqeqeq": 2,
|
|
6
7
|
"comma-dangle": 0,
|
|
7
|
-
|
|
8
|
+
curly: 0,
|
|
8
9
|
"no-console": 1,
|
|
9
10
|
"no-debugger": 1,
|
|
10
11
|
"no-extra-semi": 2,
|
|
@@ -24,7 +25,32 @@ module.exports = {
|
|
|
24
25
|
"requireReturnDescription": false
|
|
25
26
|
}
|
|
26
27
|
],
|
|
27
|
-
"radix": 0
|
|
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,
|
|
28
55
|
},
|
|
29
|
-
"parser": "babel-eslint"
|
|
30
56
|
};
|
package/Migration.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Migration to the New Architecture
|
|
2
|
+
|
|
3
|
+
This file is a tracker for what has been done to work on the migration of this library and to keep also track of the various todo:
|
|
4
|
+
|
|
5
|
+
## TODO
|
|
6
|
+
|
|
7
|
+
- [] Write JS spec in Flow for the New Architecture
|
|
8
|
+
- [] Implent the new Native Code on iOS
|
|
9
|
+
- [] Implent the new Native Code on Android
|
|
10
|
+
- [] Test on OldArch app (iOS)
|
|
11
|
+
- [] Test on OldArch app (Android)
|
|
12
|
+
- [] Test on NewArch app (iOS)
|
|
13
|
+
- [] Test on NewArch app (Android)
|
|
14
|
+
- [] Open PR
|
|
15
|
+
|
|
16
|
+
## Done
|
|
17
|
+
|
|
18
|
+
### Setup
|
|
19
|
+
1. Forked and cloned the repo
|
|
20
|
+
1. Checked the list of APIs to migrate.
|
|
21
|
+
1. Created an `OldArch` app (0.70) configured for the Old Architecture.
|
|
22
|
+
1. Run the app to make sure that it works properly.
|
|
23
|
+
1. Created a `NewArch` app (0.70) configured for the New Architecture.
|
|
24
|
+
1. Switched the flags for iOS and Android to have the new arch enabled by default
|
|
25
|
+
1. Run the app to make sure that it works properly.
|
|
26
|
+
1. Moved the apps in the `examples` folder
|
|
27
|
+
|
|
28
|
+
### Installing blob-utils
|
|
29
|
+
1. Move to `OldArch`
|
|
30
|
+
1. Run `yarn add ../..` to install the blob utils.
|
|
31
|
+
1. `cd ios`
|
|
32
|
+
1. `bundle install && bundle exec pod install`
|
|
33
|
+
1. `cd ..`
|
|
34
|
+
1. `npx react-native run-ios`
|
|
35
|
+
1. Copy the app JS code from `examples/ReactNativeBlobUtil/App.js` to `examples/OldArch/App.js`
|
|
36
|
+
1. Fixed various JS issues
|
|
37
|
+
1. The app depends on the `Picker`. *Note:* It does not support the New Arch, we need to figure out another way to choose.
|
|
38
|
+
1. run `yarn add @react-native-picker/picker`
|
|
39
|
+
1. run `bundle exec pod install` from the iOS folder
|
|
40
|
+
1. re-run the app
|
|
41
|
+
1. Repeat the above steps for `NewArch`
|
package/README.md
CHANGED
|
@@ -12,11 +12,13 @@ The project will be continued in this repository. React-Native-Blob-Util is full
|
|
|
12
12
|
|
|
13
13
|
# Version Compatibility Warning
|
|
14
14
|
|
|
15
|
-
react-native-blob-util version 0.
|
|
15
|
+
react-native-blob-util version **0.17.0** and up is only compatible with react native **0.64** and up.
|
|
16
|
+
|
|
17
|
+
react-native-blob-util version **0.10.16** and up is only compatible with react native **0.60** and up.
|
|
16
18
|
|
|
17
19
|
## Features
|
|
18
20
|
|
|
19
|
-
- Access and write data to Android
|
|
21
|
+
- Access and write data to Android Media Store (e.g. Downloads folder on devices > Android 9)
|
|
20
22
|
- Transfer data directly from/to storage without BASE64 bridging
|
|
21
23
|
- File API supports regular files, Asset files, and CameraRoll files
|
|
22
24
|
- Native-to-native file manipulation API, reduce JS bridging performance loss
|
|
@@ -24,6 +26,11 @@ react-native-blob-util version 0.10.16 and up is only compatible with react nati
|
|
|
24
26
|
- Blob, File, XMLHttpRequest polyfills that make browser-based library available in RN (experimental)
|
|
25
27
|
- JSON stream supported base on [Oboe.js](https://github.com/jimhigson/oboe.js/) @jimhigson
|
|
26
28
|
|
|
29
|
+
## React Native New Architecture
|
|
30
|
+
With Reacht 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.
|
|
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
|
+
|
|
27
34
|
## Android 10 & 11
|
|
28
35
|
|
|
29
36
|
Android 10 introduced scoped storage for apps. Apps no longer can create own directories directly on the external storage or access files outside the apps own directories. With version 0.14.0 support for the media storage is implemented. For more information please see the chapter about the mediastore API.
|
|
@@ -971,7 +978,7 @@ After `0.8.0` we've made some [Web API polyfills](https://github.com/RonRadtke/r
|
|
|
971
978
|
|
|
972
979
|
## Setting A File Transformer
|
|
973
980
|
|
|
974
|
-
Setting a file transformer will allow you to specify how data should be transformed whenever the library is writing into storage or reading from storage. A use case for this is if you want the files handled by this library to be encrypted.
|
|
981
|
+
Setting a file transformer will allow you to specify how data should be transformed whenever the library is writing into storage or reading from storage. A use case for this is if you want the files handled by this library to be encrypted.
|
|
975
982
|
|
|
976
983
|
If you want to use a file transformer, you must implement an interface defined in:
|
|
977
984
|
|
|
@@ -988,7 +995,7 @@ public class MainApplication extends Application implements ReactApplication {
|
|
|
988
995
|
@Override
|
|
989
996
|
public void onCreate() {
|
|
990
997
|
...
|
|
991
|
-
ReactNativeBlobUtilFileTransformer.sharedFileTransformer = new MyCustomEncryptor();
|
|
998
|
+
ReactNativeBlobUtilFileTransformer.sharedFileTransformer = new MyCustomEncryptor();
|
|
992
999
|
...
|
|
993
1000
|
}
|
|
994
1001
|
```
|
|
@@ -1005,8 +1012,8 @@ iOS:
|
|
|
1005
1012
|
}
|
|
1006
1013
|
```
|
|
1007
1014
|
|
|
1008
|
-
Here are the places where the transformer would apply
|
|
1009
|
-
- Reading a file from the file system
|
|
1015
|
+
Here are the places where the transformer would apply
|
|
1016
|
+
- Reading a file from the file system
|
|
1010
1017
|
- Writing a file into the file system
|
|
1011
1018
|
- Http response is downloaded to storage directly
|
|
1012
1019
|
|
package/android/build.gradle
CHANGED
|
@@ -30,11 +30,19 @@ buildscript {
|
|
|
30
30
|
mavenCentral()
|
|
31
31
|
}
|
|
32
32
|
dependencies {
|
|
33
|
-
classpath 'com.android.tools.build:gradle:
|
|
33
|
+
classpath 'com.android.tools.build:gradle:7.2.1'
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
def isNewArchitectureEnabled() {
|
|
39
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (isNewArchitectureEnabled()) {
|
|
43
|
+
apply plugin: 'com.facebook.react'
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
android {
|
|
39
47
|
compileSdkVersion safeExtGet('compileSdkVersion', 30)
|
|
40
48
|
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
|
|
@@ -43,6 +51,7 @@ android {
|
|
|
43
51
|
targetSdkVersion safeExtGet('targetSdkVersion', 30)
|
|
44
52
|
versionCode 1
|
|
45
53
|
versionName "1.0"
|
|
54
|
+
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
|
|
46
55
|
}
|
|
47
56
|
buildTypes {
|
|
48
57
|
release {
|
|
@@ -55,6 +64,15 @@ android {
|
|
|
55
64
|
}
|
|
56
65
|
productFlavors {
|
|
57
66
|
}
|
|
67
|
+
sourceSets {
|
|
68
|
+
main {
|
|
69
|
+
if (isNewArchitectureEnabled()) {
|
|
70
|
+
java.srcDirs += ['src/newarch']
|
|
71
|
+
} else {
|
|
72
|
+
java.srcDirs += ['src/oldarch']
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
dependencies {
|
|
@@ -173,7 +173,7 @@ class ReactNativeBlobUtilBody extends RequestBody {
|
|
|
173
173
|
if (ReactNativeBlobUtilUtils.isAsset(orgPath)) {
|
|
174
174
|
try {
|
|
175
175
|
String assetName = orgPath.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, "");
|
|
176
|
-
return
|
|
176
|
+
return ReactNativeBlobUtilImpl.RCTContext.getAssets().open(assetName);
|
|
177
177
|
} catch (Exception e) {
|
|
178
178
|
throw new Exception("error when getting request stream from asset : " + e.getLocalizedMessage());
|
|
179
179
|
}
|
|
@@ -190,7 +190,7 @@ class ReactNativeBlobUtilBody extends RequestBody {
|
|
|
190
190
|
} else if (rawBody.startsWith(ReactNativeBlobUtilConst.CONTENT_PREFIX)) {
|
|
191
191
|
String contentURI = rawBody.substring(ReactNativeBlobUtilConst.CONTENT_PREFIX.length());
|
|
192
192
|
try {
|
|
193
|
-
return
|
|
193
|
+
return ReactNativeBlobUtilImpl.RCTContext.getContentResolver().openInputStream(Uri.parse(contentURI));
|
|
194
194
|
} catch (Exception e) {
|
|
195
195
|
throw new Exception("error when getting request stream for content URI: " + contentURI, e);
|
|
196
196
|
}
|
|
@@ -215,12 +215,12 @@ class ReactNativeBlobUtilBody extends RequestBody {
|
|
|
215
215
|
private File createMultipartBodyCache() throws IOException {
|
|
216
216
|
String boundary = "ReactNativeBlobUtil-" + mTaskId;
|
|
217
217
|
|
|
218
|
-
File outputDir =
|
|
218
|
+
File outputDir = ReactNativeBlobUtilImpl.RCTContext.getCacheDir(); // context being the Activity pointer
|
|
219
219
|
File outputFile = File.createTempFile("rnfb-form-tmp", "", outputDir);
|
|
220
220
|
FileOutputStream os = new FileOutputStream(outputFile);
|
|
221
221
|
|
|
222
222
|
ArrayList<FormField> fields = countFormDataLength();
|
|
223
|
-
ReactApplicationContext ctx =
|
|
223
|
+
ReactApplicationContext ctx = ReactNativeBlobUtilImpl.RCTContext;
|
|
224
224
|
|
|
225
225
|
for (FormField field : fields) {
|
|
226
226
|
String data = field.data;
|
|
@@ -344,7 +344,7 @@ class ReactNativeBlobUtilBody extends RequestBody {
|
|
|
344
344
|
private ArrayList<FormField> countFormDataLength() throws IOException {
|
|
345
345
|
long total = 0;
|
|
346
346
|
ArrayList<FormField> list = new ArrayList<>();
|
|
347
|
-
ReactApplicationContext ctx =
|
|
347
|
+
ReactApplicationContext ctx = ReactNativeBlobUtilImpl.RCTContext;
|
|
348
348
|
for (int i = 0; i < form.size(); i++) {
|
|
349
349
|
FormField field = new FormField(form.getMap(i));
|
|
350
350
|
list.add(field);
|
|
@@ -442,7 +442,7 @@ class ReactNativeBlobUtilBody extends RequestBody {
|
|
|
442
442
|
args.putString("total", String.valueOf(contentLength));
|
|
443
443
|
|
|
444
444
|
// emit event to js context
|
|
445
|
-
|
|
445
|
+
ReactNativeBlobUtilImpl.RCTContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
446
446
|
.emit(ReactNativeBlobUtilConst.EVENT_UPLOAD_PROGRESS, args);
|
|
447
447
|
}
|
|
448
448
|
}
|
|
@@ -258,15 +258,15 @@ class ReactNativeBlobUtilFS {
|
|
|
258
258
|
if (resolved != null && resolved.startsWith(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET)) {
|
|
259
259
|
String assetName = path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, "");
|
|
260
260
|
// This fails should an asset file be >2GB
|
|
261
|
-
length = (int)
|
|
261
|
+
length = (int) ReactNativeBlobUtilImpl.RCTContext.getAssets().openFd(assetName).getLength();
|
|
262
262
|
bytes = new byte[length];
|
|
263
|
-
InputStream in =
|
|
263
|
+
InputStream in = ReactNativeBlobUtilImpl.RCTContext.getAssets().open(assetName);
|
|
264
264
|
bytesRead = in.read(bytes, 0, length);
|
|
265
265
|
in.close();
|
|
266
266
|
}
|
|
267
267
|
// issue 287
|
|
268
268
|
else if (resolved == null) {
|
|
269
|
-
InputStream in =
|
|
269
|
+
InputStream in = ReactNativeBlobUtilImpl.RCTContext.getContentResolver().openInputStream(Uri.parse(path));
|
|
270
270
|
// TODO See https://developer.android.com/reference/java/io/InputStream.html#available()
|
|
271
271
|
// Quote: "Note that while some implementations of InputStream will return the total number of bytes
|
|
272
272
|
// in the stream, many will not. It is never correct to use the return value of this method to
|
|
@@ -358,6 +358,10 @@ class ReactNativeBlobUtilFS {
|
|
|
358
358
|
}
|
|
359
359
|
res.put("MainBundleDir", ctx.getApplicationInfo().dataDir);
|
|
360
360
|
|
|
361
|
+
// TODO Change me with the correct path
|
|
362
|
+
res.put("LibraryDir", "");
|
|
363
|
+
res.put("ApplicationSupportDir", "");
|
|
364
|
+
|
|
361
365
|
return res;
|
|
362
366
|
}
|
|
363
367
|
|
|
@@ -441,7 +445,7 @@ class ReactNativeBlobUtilFS {
|
|
|
441
445
|
* @return String
|
|
442
446
|
*/
|
|
443
447
|
static String getTmpPath(String taskId) {
|
|
444
|
-
return
|
|
448
|
+
return ReactNativeBlobUtilImpl.RCTContext.getFilesDir() + "/ReactNativeBlobUtilTmp_" + taskId;
|
|
445
449
|
}
|
|
446
450
|
|
|
447
451
|
|
|
@@ -614,7 +618,7 @@ class ReactNativeBlobUtilFS {
|
|
|
614
618
|
if (isAsset(path)) {
|
|
615
619
|
try {
|
|
616
620
|
String filename = path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, "");
|
|
617
|
-
com.ReactNativeBlobUtil.
|
|
621
|
+
com.ReactNativeBlobUtil.ReactNativeBlobUtilImpl.RCTContext.getAssets().openFd(filename);
|
|
618
622
|
callback.invoke(true, false);
|
|
619
623
|
} catch (IOException e) {
|
|
620
624
|
callback.invoke(false, false);
|
|
@@ -779,7 +783,7 @@ class ReactNativeBlobUtilFS {
|
|
|
779
783
|
WritableMap stat = Arguments.createMap();
|
|
780
784
|
if (isAsset(path)) {
|
|
781
785
|
String name = path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, "");
|
|
782
|
-
AssetFileDescriptor fd =
|
|
786
|
+
AssetFileDescriptor fd = ReactNativeBlobUtilImpl.RCTContext.getAssets().openFd(name);
|
|
783
787
|
stat.putString("filename", name);
|
|
784
788
|
stat.putString("path", path);
|
|
785
789
|
stat.putString("type", "asset");
|
|
@@ -1020,7 +1024,7 @@ class ReactNativeBlobUtilFS {
|
|
|
1020
1024
|
*/
|
|
1021
1025
|
private static InputStream inputStreamFromPath(String path) throws IOException {
|
|
1022
1026
|
if (path.startsWith(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET)) {
|
|
1023
|
-
return
|
|
1027
|
+
return ReactNativeBlobUtilImpl.RCTContext.getAssets().open(path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, ""));
|
|
1024
1028
|
}
|
|
1025
1029
|
return new FileInputStream(new File(path));
|
|
1026
1030
|
}
|
|
@@ -1034,7 +1038,7 @@ class ReactNativeBlobUtilFS {
|
|
|
1034
1038
|
private static boolean isPathExists(String path) {
|
|
1035
1039
|
if (path.startsWith(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET)) {
|
|
1036
1040
|
try {
|
|
1037
|
-
|
|
1041
|
+
ReactNativeBlobUtilImpl.RCTContext.getAssets().open(path.replace(com.ReactNativeBlobUtil.ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, ""));
|
|
1038
1042
|
} catch (IOException e) {
|
|
1039
1043
|
return false;
|
|
1040
1044
|
}
|