react-native-blob-util 0.16.3 → 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.
Files changed (76) hide show
  1. package/.eslintrc.js +29 -3
  2. package/Migration.md +41 -0
  3. package/README.md +13 -6
  4. package/android/build.gradle +19 -1
  5. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilBody.java +6 -6
  6. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java +12 -8
  7. package/android/src/main/java/com/ReactNativeBlobUtil/{ReactNativeBlobUtil.java → ReactNativeBlobUtilImpl.java} +19 -78
  8. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilMediaCollection.java +5 -5
  9. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilPackage.java +31 -21
  10. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java +25 -23
  11. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilStream.java +6 -6
  12. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilUtils.java +2 -2
  13. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/MimeType.java +1 -1
  14. package/android/src/newarch/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java +281 -0
  15. package/android/src/oldarch/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java +242 -0
  16. package/android.js +2 -3
  17. package/class/ReactNativeBlobUtilFile.js +1 -13
  18. package/class/ReactNativeBlobUtilReadStream.js +1 -2
  19. package/class/ReactNativeBlobUtilSession.js +1 -2
  20. package/class/ReactNativeBlobUtilWriteStream.js +1 -3
  21. package/codegenSpecs/NativeBlobUtils.js +77 -0
  22. package/fetch.js +2 -2
  23. package/fs.js +15 -22
  24. package/index.js +2 -2
  25. package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.h +10 -1
  26. package/ios/ReactNativeBlobUtil/{ReactNativeBlobUtil.m → ReactNativeBlobUtil.mm} +334 -41
  27. package/ios/{ReactNativeBlobUtilConst.m → ReactNativeBlobUtilConst.mm} +0 -0
  28. package/ios/ReactNativeBlobUtilFS.h +5 -5
  29. package/ios/{ReactNativeBlobUtilFS.m → ReactNativeBlobUtilFS.mm} +32 -26
  30. package/ios/{ReactNativeBlobUtilFileTransformer.m → ReactNativeBlobUtilFileTransformer.mm} +0 -0
  31. package/ios/ReactNativeBlobUtilNetwork.h +2 -2
  32. package/ios/{ReactNativeBlobUtilNetwork.m → ReactNativeBlobUtilNetwork.mm} +15 -17
  33. package/ios/{ReactNativeBlobUtilProgress.m → ReactNativeBlobUtilProgress.mm} +4 -4
  34. package/ios/{ReactNativeBlobUtilReqBuilder.m → ReactNativeBlobUtilReqBuilder.mm} +4 -4
  35. package/ios/ReactNativeBlobUtilRequest.h +4 -2
  36. package/ios/{ReactNativeBlobUtilRequest.m → ReactNativeBlobUtilRequest.mm} +16 -11
  37. package/ios.js +2 -3
  38. package/mediacollection.js +2 -4
  39. package/package.json +7 -2
  40. package/react-native-blob-util.podspec +21 -1
  41. package/examples/ReactNativeBlobUtil/.buckconfig +0 -6
  42. package/examples/ReactNativeBlobUtil/.eslintrc.js +0 -4
  43. package/examples/ReactNativeBlobUtil/.prettierrc.js +0 -6
  44. package/examples/ReactNativeBlobUtil/App.js +0 -698
  45. package/examples/ReactNativeBlobUtil/index.js +0 -9
  46. package/examples/ReactNativeBlobUtil/metro.config.js +0 -27
  47. package/examples/ReactNativeBlobUtil/package.json +0 -31
  48. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.cpp +0 -80
  49. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.h +0 -20
  50. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.idl +0 -3
  51. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/App.xaml +0 -10
  52. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/LockScreenLogo.scale-200.png +0 -0
  53. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/SplashScreen.scale-200.png +0 -0
  54. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Square150x150Logo.scale-200.png +0 -0
  55. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Square44x44Logo.scale-200.png +0 -0
  56. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Square44x44Logo.targetsize-24_altform-unplated.png +0 -0
  57. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/StoreLogo.png +0 -0
  58. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Assets/Wide310x150Logo.scale-200.png +0 -0
  59. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/AutolinkedNativeModules.g.cpp +0 -18
  60. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/AutolinkedNativeModules.g.h +0 -10
  61. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/AutolinkedNativeModules.g.targets +0 -11
  62. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.cpp +0 -24
  63. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.h +0 -21
  64. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.idl +0 -8
  65. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/MainPage.xaml +0 -16
  66. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/Package.appxmanifest +0 -50
  67. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/PropertySheet.props +0 -16
  68. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactNativeBlobUtilWin.vcxproj +0 -196
  69. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactNativeBlobUtilWin.vcxproj.filters +0 -65
  70. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactNativeBlobUtilWin_TemporaryKey.pfx +0 -0
  71. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactPackageProvider.cpp +0 -18
  72. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/ReactPackageProvider.h +0 -15
  73. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/packages.config +0 -5
  74. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/pch.cpp +0 -1
  75. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin/pch.h +0 -26
  76. package/examples/ReactNativeBlobUtil/windows/ReactNativeBlobUtilWin.sln +0 -207
@@ -37,12 +37,12 @@ public class ReactNativeBlobUtilStream {
37
37
 
38
38
  /**
39
39
  * Create a file stream for read
40
- *
41
- * @param path File stream target path
40
+ * @param path File stream target path
42
41
  * @param encoding File stream decoder, should be one of `base64`, `utf8`, `ascii`
43
42
  * @param bufferSize Buffer size of read stream, default to 4096 (4095 when encode is `base64`)
43
+ * @param RCTContext
44
44
  */
45
- void readStream(String path, String encoding, int bufferSize, int tick, final String streamId) {
45
+ void readStream(String path, String encoding, int bufferSize, int tick, final String streamId, ReactApplicationContext RCTContext) {
46
46
  String resolved = ReactNativeBlobUtilUtils.normalizePath(path);
47
47
  if (resolved != null)
48
48
  path = resolved;
@@ -55,11 +55,11 @@ public class ReactNativeBlobUtilStream {
55
55
  InputStream fs;
56
56
 
57
57
  if (resolved != null && path.startsWith(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET)) {
58
- fs = ReactNativeBlobUtil.RCTContext.getAssets().open(path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, ""));
58
+ fs = ReactNativeBlobUtilImpl.RCTContext.getAssets().open(path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, ""));
59
59
  }
60
60
  // fix issue 287
61
61
  else if (resolved == null) {
62
- fs = ReactNativeBlobUtil.RCTContext.getContentResolver().openInputStream(Uri.parse(path));
62
+ fs = ReactNativeBlobUtilImpl.RCTContext.getContentResolver().openInputStream(Uri.parse(path));
63
63
  } else {
64
64
  fs = new FileInputStream(new File(path));
65
65
  }
@@ -279,7 +279,7 @@ public class ReactNativeBlobUtilStream {
279
279
  */
280
280
  public static InputStream inputStreamFromPath(String path) throws IOException {
281
281
  if (path.startsWith(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET)) {
282
- return ReactNativeBlobUtil.RCTContext.getAssets().open(path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, ""));
282
+ return ReactNativeBlobUtilImpl.RCTContext.getAssets().open(path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, ""));
283
283
  }
284
284
  return new FileInputStream(new File(path));
285
285
  }
@@ -55,7 +55,7 @@ public class ReactNativeBlobUtilUtils {
55
55
  args.putString("detail", data);
56
56
 
57
57
  // emit event to js context
58
- ReactNativeBlobUtil.RCTContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
58
+ ReactNativeBlobUtilImpl.RCTContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
59
59
  .emit(ReactNativeBlobUtilConst.EVENT_MESSAGE, args);
60
60
  }
61
61
 
@@ -125,7 +125,7 @@ public class ReactNativeBlobUtilUtils {
125
125
  if (path.startsWith(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET)) {
126
126
  return path;
127
127
  } else
128
- return PathResolver.getRealPathFromURI(ReactNativeBlobUtil.RCTContext, uri);
128
+ return PathResolver.getRealPathFromURI(ReactNativeBlobUtilImpl.RCTContext, uri);
129
129
  }
130
130
 
131
131
  public static boolean isAsset(String path) {
@@ -27,7 +27,7 @@ public class MimeType {
27
27
  public static String getFullFileName(String name, String mimeType) {
28
28
  // Prior to API 29, MimeType.BINARY_FILE has no file extension
29
29
  String ext = MimeType.getExtensionFromMimeType(mimeType);
30
- if (ext.isEmpty() || name.endsWith("." + "ext")) return name;
30
+ if ((ext == null || ext.isEmpty()) || name.endsWith("." + "ext")) return name;
31
31
  else {
32
32
  String fn = name + "." + ext;
33
33
  if (fn.endsWith(".")) return StringUtils.stripEnd(fn, ".");
@@ -0,0 +1,281 @@
1
+ package com.ReactNativeBlobUtil;
2
+
3
+ import android.os.Build;
4
+
5
+ import androidx.annotation.NonNull;
6
+ import androidx.annotation.RequiresApi;
7
+
8
+ import com.facebook.fbreact.specs.NativeBlobUtilsSpec;
9
+ import com.facebook.react.bridge.Callback;
10
+ import com.facebook.react.bridge.Promise;
11
+ import com.facebook.react.bridge.ReactApplicationContext;
12
+ import com.facebook.react.bridge.ReadableArray;
13
+ import com.facebook.react.bridge.ReadableMap;
14
+
15
+ import java.util.HashMap;
16
+ import java.util.Map;
17
+
18
+ import javax.annotation.Nullable;
19
+
20
+ public class ReactNativeBlobUtil extends NativeBlobUtilsSpec {
21
+
22
+ private final ReactNativeBlobUtilImpl delegate;
23
+
24
+ public ReactNativeBlobUtil(ReactApplicationContext reactContext) {
25
+ super(reactContext);
26
+ delegate = new ReactNativeBlobUtilImpl(reactContext);
27
+ }
28
+
29
+ @Override
30
+ protected Map<String, Object> getTypedExportedConstants() {
31
+ Map<String, Object> res = new HashMap<>();
32
+ res.putAll(ReactNativeBlobUtilFS.getSystemfolders(this.getReactApplicationContext()));
33
+ res.putAll(ReactNativeBlobUtilFS.getLegacySystemfolders(this.getReactApplicationContext()));
34
+ return res;
35
+ }
36
+
37
+ @NonNull
38
+ @Override
39
+ public String getName() {
40
+ return ReactNativeBlobUtilImpl.NAME;
41
+ }
42
+
43
+ @Override
44
+ public void fetchBlobForm(ReadableMap options, String taskId, String method, String url, ReadableMap headers, ReadableArray form, Callback callback) {
45
+ delegate.fetchBlobForm(options, taskId, method, url, headers, form, callback);
46
+ }
47
+
48
+ @Override
49
+ public void fetchBlob(ReadableMap options, String taskId, String method, String url, ReadableMap headers, String body, Callback callback) {
50
+ delegate.fetchBlob(options, taskId, method, url, headers, body, callback);
51
+ }
52
+
53
+ @Override
54
+ public void createFile(String path, String data, String encoding, Promise promise) {
55
+ delegate.createFile(path, data, encoding, promise);
56
+ }
57
+
58
+ @Override
59
+ public void createFileASCII(String path, ReadableArray data, Promise promise) {
60
+ delegate.createFileASCII(path, data, promise);
61
+ }
62
+
63
+
64
+ @Override
65
+ public void pathForAppGroup(String groupName, Promise promise) {
66
+ // Not implemented as ReactNativeBlobUtil.pathForAppGroup only supports IOS
67
+ // This will be rejected at the iOS layer
68
+ }
69
+
70
+ @Override
71
+ public String syncPathAppGroup(String groupName) {
72
+ // Not implemented as ReactNativeBlobUtil.syncPathAppGroup only supports IOS
73
+ // This will be rejected at the iOS layer
74
+ return null;
75
+ }
76
+
77
+ @Override
78
+ public void exists(String path, Callback callback) {
79
+ delegate.exists(path, callback);
80
+ }
81
+
82
+ @Override
83
+ public void writeFile(String path, String encoding, String data, boolean transformFile, boolean append, Promise promise) {
84
+ delegate.writeFile(path, encoding, data, transformFile, append, promise);
85
+ }
86
+
87
+ @Override
88
+ public void writeFileArray(String path, ReadableArray data, boolean append, Promise promise) {
89
+ delegate.writeFileArray(path, data, append, promise);
90
+ }
91
+
92
+ @Override
93
+ public void writeStream(String path, String withEncoding, boolean appendData, Callback callback) {
94
+ delegate.writeStream(path, withEncoding, appendData, callback);
95
+ }
96
+
97
+ @Override
98
+ public void writeArrayChunk(String streamId, ReadableArray withArray, Callback callback) {
99
+ delegate.writeArrayChunk(streamId, withArray, callback);
100
+ }
101
+
102
+ @Override
103
+ public void writeChunk(String streamId, String withData, Callback callback) {
104
+ delegate.writeChunk(streamId, withData, callback);
105
+ }
106
+
107
+ @Override
108
+ public void closeStream(String streamId, Callback callback) {
109
+ delegate.closeStream(streamId, callback);
110
+ }
111
+
112
+ @Override
113
+ public void unlink(String path, Callback callback) {
114
+ delegate.unlink(path, callback);
115
+ }
116
+
117
+ @Override
118
+ public void removeSession(ReadableArray paths, Callback callback) {
119
+ delegate.removeSession(paths, callback);
120
+ }
121
+
122
+ @Override
123
+ public void ls(String path, Promise promise) {
124
+ delegate.ls(path, promise);
125
+ }
126
+
127
+ @Override
128
+ public void stat(String target, Callback callback) {
129
+ delegate.stat(target, callback);
130
+ }
131
+
132
+ @Override
133
+ public void lstat(String path, Callback callback) {
134
+ delegate.lstat(path, callback);
135
+ }
136
+
137
+ @Override
138
+ public void cp(String src, String dest, Callback callback) {
139
+ delegate.cp(src, dest, callback);
140
+ }
141
+
142
+ @Override
143
+ public void mv(String path, String dest, Callback callback) {
144
+ delegate.mv(path, dest, callback);
145
+ }
146
+
147
+ @Override
148
+ public void mkdir(String path, Promise promise) {
149
+ delegate.mkdir(path, promise);
150
+ }
151
+
152
+ @Override
153
+ public void readFile(String path, String encoding, boolean transformFile, Promise promise) {
154
+ delegate.readFile(path, encoding, transformFile, promise);
155
+ }
156
+
157
+ @Override
158
+ public void hash(String path, String algorithm, Promise promise) {
159
+ delegate.hash(path, algorithm, promise);
160
+ }
161
+
162
+ @Override
163
+ public void readStream(String path, String encoding, double bufferSize, double tick, String streamId) {
164
+ delegate.readStream(path, encoding, (int) bufferSize, (int) tick, streamId);
165
+ }
166
+
167
+ @Override
168
+ public void getEnvironmentDirs(Callback callback) {
169
+ // Not implemented as ReactNativeBlobUtil.getEnvironmentDirs only supports IOS
170
+ }
171
+
172
+ @Override
173
+ public void cancelRequest(String taskId, Callback callback) {
174
+ delegate.cancelRequest(taskId, callback);
175
+ }
176
+
177
+ @Override
178
+ public void enableProgressReport(String taskId, double interval, double count) {
179
+ delegate.enableProgressReport(taskId, (int) interval, (int) count);
180
+ }
181
+
182
+ @Override
183
+ public void enableUploadProgressReport(String taskId, double interval, double count) {
184
+ delegate.enableUploadProgressReport(taskId, (int) interval, (int) count);
185
+ }
186
+
187
+ @Override
188
+ public void slice(String src, String dest, double start, double end, Promise promise) {
189
+ delegate.slice(src, dest, (int) start, (int) end, promise);
190
+ }
191
+
192
+ @Override
193
+ public void presentOptionsMenu(String uri, String scheme, Promise promise) {
194
+ // Not implemented as ReactNativeBlobUtil.presentOptionsMenu only supports IOS
195
+ // This will be rejected at the iOS layer
196
+ }
197
+
198
+ @Override
199
+ public void presentOpenInMenu(String uri, String scheme, Promise promise) {
200
+ // Not implemented as ReactNativeBlobUtil.presentOpenInMenu only supports IOS
201
+ // This will be rejected at the iOS layer
202
+ }
203
+
204
+ @Override
205
+ public void presentPreview(String uri, String scheme, Promise promise) {
206
+ // Not implemented as ReactNativeBlobUtil.presentPreview only supports IOS
207
+ // This will be rejected at the iOS layer
208
+ }
209
+
210
+ @Override
211
+ public void excludeFromBackupKey(String url, Promise promise) {
212
+ // Not implemented as ReactNativeBlobUtil.excludeFromBackupKey only supports IOS
213
+ }
214
+
215
+ @Override
216
+ public void df(Callback callback) {
217
+ delegate.df(callback);
218
+ }
219
+
220
+ @Override
221
+ public void emitExpiredEvent(Callback callback) {
222
+ // Not implemented as ReactNativeBlobUtil.emitExpiredEvent only supports IOS
223
+ }
224
+
225
+ @Override
226
+ public void actionViewIntent(String path, String mime, String chooserTitle, Promise promise) {
227
+ delegate.actionViewIntent(path, mime, chooserTitle, promise);
228
+ }
229
+
230
+ @Override
231
+ public void addCompleteDownload(ReadableMap config, Promise promise) {
232
+ delegate.addCompleteDownload(config, promise);
233
+ }
234
+
235
+ @RequiresApi(api = Build.VERSION_CODES.Q)
236
+ @Override
237
+ public void copyToInternal(String contentUri, String destpath, Promise promise) {
238
+ delegate.copyToInternal(contentUri, destpath, promise);
239
+ }
240
+
241
+ @Override
242
+ public void copyToMediaStore(ReadableMap filedata, String mt, String path, Promise promise) {
243
+ delegate.copyToMediaStore(filedata, mt, path, promise);
244
+ }
245
+
246
+ @Override
247
+ public void createMediaFile(ReadableMap filedata, String mt, Promise promise) {
248
+ delegate.createMediaFile(filedata, mt, promise);
249
+ }
250
+
251
+ @RequiresApi(api = Build.VERSION_CODES.Q)
252
+ @Override
253
+ public void getBlob(String contentUri, String encoding, Promise promise) {
254
+ delegate.getBlob(contentUri, encoding, promise);
255
+ }
256
+
257
+ @Override
258
+ public void getContentIntent(String mime, Promise promise) {
259
+ delegate.getContentIntent(mime, promise);
260
+ }
261
+
262
+ @Override
263
+ public void getSDCardDir(Promise promise) {
264
+ delegate.getSDCardDir(promise);
265
+ }
266
+
267
+ @Override
268
+ public void getSDCardApplicationDir(Promise promise) {
269
+ delegate.getSDCardApplicationDir(promise);
270
+ }
271
+
272
+ @Override
273
+ public void scanFile(final ReadableArray pairs, final Callback callback) {
274
+ delegate.scanFile(pairs, callback);
275
+ }
276
+
277
+ @Override
278
+ public void writeToMediaFile(String fileUri, String path, boolean transformFile, Promise promise) {
279
+ delegate.writeToMediaFile(fileUri, path, transformFile, promise);
280
+ }
281
+ }
@@ -0,0 +1,242 @@
1
+ package com.ReactNativeBlobUtil;
2
+
3
+ import android.os.Build;
4
+
5
+ import androidx.annotation.NonNull;
6
+ import androidx.annotation.RequiresApi;
7
+
8
+ import com.facebook.react.bridge.Callback;
9
+ import com.facebook.react.bridge.Promise;
10
+ import com.facebook.react.bridge.ReactApplicationContext;
11
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
+ import com.facebook.react.bridge.ReactMethod;
13
+ import com.facebook.react.bridge.ReadableArray;
14
+ import com.facebook.react.bridge.ReadableMap;
15
+
16
+ import java.util.HashMap;
17
+ import java.util.Map;
18
+
19
+ import javax.annotation.Nullable;
20
+
21
+ public class ReactNativeBlobUtil extends ReactContextBaseJavaModule {
22
+
23
+ private final ReactNativeBlobUtilImpl delegate;
24
+
25
+ public ReactNativeBlobUtil(ReactApplicationContext reactContext) {
26
+ super(reactContext);
27
+ delegate = new ReactNativeBlobUtilImpl(reactContext);
28
+ }
29
+
30
+ @NonNull
31
+ @Override
32
+ public String getName() {
33
+ return ReactNativeBlobUtilImpl.NAME;
34
+ }
35
+
36
+ @Override
37
+ public Map<String, Object> getConstants() {
38
+ Map<String, Object> res = new HashMap<>();
39
+ res.putAll(ReactNativeBlobUtilFS.getSystemfolders(this.getReactApplicationContext()));
40
+ res.putAll(ReactNativeBlobUtilFS.getLegacySystemfolders(this.getReactApplicationContext()));
41
+
42
+ return res;
43
+ }
44
+
45
+ @ReactMethod
46
+ public void createFile(final String path, final String content, final String encode, final Promise promise) {
47
+ delegate.createFile(path, content, encode, promise);
48
+ }
49
+
50
+ @ReactMethod
51
+ public void createFileASCII(final String path, final ReadableArray dataArray, final Promise promise) {
52
+ delegate.createFileASCII(path, dataArray, promise);
53
+ }
54
+
55
+ @ReactMethod
56
+ public void actionViewIntent(String path, String mime, @Nullable String chooserTitle, final Promise promise) {
57
+ delegate.actionViewIntent(path, mime, chooserTitle, promise);
58
+ }
59
+
60
+ @ReactMethod
61
+ public void writeArrayChunk(final String streamId, final ReadableArray dataArray, final Callback callback) {
62
+ delegate.writeArrayChunk(streamId, dataArray, callback);
63
+ }
64
+
65
+ @ReactMethod
66
+ public void unlink(String path, Callback callback) {
67
+ delegate.unlink(path, callback);
68
+ }
69
+
70
+ @ReactMethod
71
+ public void mkdir(String path, Promise promise) {
72
+ delegate.mkdir(path, promise);
73
+ }
74
+
75
+ @ReactMethod
76
+ public void exists(String path, Callback callback) {
77
+ delegate.exists(path, callback);
78
+ }
79
+
80
+ @ReactMethod
81
+ public void cp(final String path, final String dest, final Callback callback) {
82
+ delegate.cp(path, dest, callback);
83
+ }
84
+
85
+ @ReactMethod
86
+ public void mv(String path, String dest, Callback callback) {
87
+ delegate.mv(path, dest, callback);
88
+ }
89
+
90
+ @ReactMethod
91
+ public void ls(String path, Promise promise) {
92
+ delegate.ls(path, promise);
93
+ }
94
+
95
+ @ReactMethod
96
+ public void writeStream(String path, String encode, boolean append, Callback callback) {
97
+ delegate.writeStream(path, encode, append, callback);
98
+ }
99
+
100
+ @ReactMethod
101
+ public void writeChunk(String streamId, String data, Callback callback) {
102
+ delegate.writeChunk(streamId, data, callback);
103
+ }
104
+
105
+ @ReactMethod
106
+ public void closeStream(String streamId, Callback callback) {
107
+ delegate.closeStream(streamId, callback);
108
+ }
109
+
110
+ @ReactMethod
111
+ public void removeSession(ReadableArray paths, Callback callback) {
112
+ delegate.removeSession(paths, callback);
113
+ }
114
+
115
+ @ReactMethod
116
+ public void readFile(final String path, final String encoding, final boolean transformFile, final Promise promise) {
117
+ delegate.readFile(path, encoding, transformFile, promise);
118
+ }
119
+
120
+ @ReactMethod
121
+ public void writeFileArray(final String path, final ReadableArray data, final boolean append, final Promise promise) {
122
+ delegate.writeFileArray(path, data, append, promise);
123
+ }
124
+
125
+ @ReactMethod
126
+ public void writeFile(final String path, final String encoding, final String data, final boolean transformFile, final boolean append, final Promise promise) {
127
+ delegate.writeFile(path, encoding, data, transformFile, append, promise);
128
+ }
129
+
130
+ @ReactMethod
131
+ public void lstat(String path, Callback callback) {
132
+ delegate.lstat(path, callback);
133
+ }
134
+
135
+ @ReactMethod
136
+ public void stat(String path, Callback callback) {
137
+ delegate.stat(path, callback);
138
+ }
139
+
140
+ @ReactMethod
141
+ public void scanFile(final ReadableArray pairs, final Callback callback) {
142
+ delegate.scanFile(pairs, callback);
143
+ }
144
+
145
+ @ReactMethod
146
+ public void hash(final String path, final String algorithm, final Promise promise) {
147
+ delegate.hash(path, algorithm, promise);
148
+ }
149
+
150
+ /**
151
+ * @param path Stream file path
152
+ * @param encoding Stream encoding, should be one of `base64`, `ascii`, and `utf8`
153
+ * @param bufferSize Stream buffer size, default to 4096 or 4095(base64).
154
+ */
155
+ @ReactMethod
156
+ public void readStream(final String path, final String encoding, final int bufferSize, final int tick, final String streamId) {
157
+ delegate.readStream(path, encoding, bufferSize, tick, streamId);
158
+ }
159
+
160
+ @ReactMethod
161
+ public void cancelRequest(String taskId, Callback callback) {
162
+ delegate.cancelRequest(taskId, callback);
163
+ }
164
+
165
+ @ReactMethod
166
+ public void slice(String src, String dest, int start, int end, Promise promise) {
167
+ delegate.slice(src, dest, start, end, promise);
168
+ }
169
+
170
+ @ReactMethod
171
+ public void enableProgressReport(String taskId, int interval, int count) {
172
+ delegate.enableProgressReport(taskId, interval, count);
173
+ }
174
+
175
+ @ReactMethod
176
+ public void df(final Callback callback) {
177
+ delegate.df(callback);
178
+ }
179
+
180
+
181
+ @ReactMethod
182
+ public void enableUploadProgressReport(String taskId, int interval, int count) {
183
+ delegate.enableUploadProgressReport(taskId, interval, count);
184
+ }
185
+
186
+ @ReactMethod
187
+ public void fetchBlob(ReadableMap options, String taskId, String method, String url, ReadableMap headers, String body, final Callback callback) {
188
+ delegate.fetchBlob(options, taskId, method, url, headers, body, callback);
189
+ }
190
+
191
+ @ReactMethod
192
+ public void fetchBlobForm(ReadableMap options, String taskId, String method, String url, ReadableMap headers, ReadableArray body, final Callback callback) {
193
+ delegate.fetchBlobForm(options, taskId, method, url, headers, body, callback);
194
+ }
195
+
196
+ @ReactMethod
197
+ public void getContentIntent(String mime, Promise promise) {
198
+ delegate.getContentIntent(mime, promise);
199
+ }
200
+
201
+ @ReactMethod
202
+ public void addCompleteDownload(ReadableMap config, Promise promise) {
203
+ delegate.addCompleteDownload(config, promise);
204
+ }
205
+
206
+ @ReactMethod
207
+ public void getSDCardDir(Promise promise) {
208
+ delegate.getSDCardDir(promise);
209
+ }
210
+
211
+ @ReactMethod
212
+ public void getSDCardApplicationDir(Promise promise) {
213
+ delegate.getSDCardApplicationDir(promise);
214
+ }
215
+
216
+ @ReactMethod
217
+ public void createMediaFile(ReadableMap filedata, String mt, Promise promise) {
218
+ delegate.createMediaFile(filedata, mt, promise);
219
+ }
220
+
221
+ @ReactMethod
222
+ public void writeToMediaFile(String fileUri, String path, boolean transformFile, Promise promise) {
223
+ delegate.writeToMediaFile(fileUri, path, transformFile, promise);
224
+ }
225
+
226
+ @RequiresApi(api = Build.VERSION_CODES.Q)
227
+ @ReactMethod
228
+ public void copyToInternal(String contentUri, String destpath, Promise promise) {
229
+ delegate.copyToInternal(contentUri, destpath, promise);
230
+ }
231
+
232
+ @RequiresApi(api = Build.VERSION_CODES.Q)
233
+ @ReactMethod
234
+ public void getBlob(String contentUri, String encoding, Promise promise) {
235
+ delegate.getBlob(contentUri, encoding, promise);
236
+ }
237
+
238
+ @ReactMethod
239
+ public void copyToMediaStore(ReadableMap filedata, String mt, String path, Promise promise) {
240
+ delegate.copyToMediaStore(filedata, mt, path, promise);
241
+ }
242
+ }
package/android.js CHANGED
@@ -2,9 +2,8 @@
2
2
  // Use of this source code is governed by a MIT-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
- import { NativeModules, Platform } from 'react-native';
6
-
7
- const ReactNativeBlobUtil = NativeModules.ReactNativeBlobUtil;
5
+ import { Platform } from 'react-native';
6
+ import ReactNativeBlobUtil from './codegenSpecs/NativeBlobUtils';
8
7
 
9
8
  /**
10
9
  * Send an intent to open the file.
@@ -2,16 +2,4 @@
2
2
  // Use of this source code is governed by a MIT-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
-
6
- import {
7
- NativeModules,
8
- DeviceEventEmitter,
9
- NativeAppEventEmitter,
10
- } from 'react-native';
11
-
12
- const ReactNativeBlobUtil = NativeModules.ReactNativeBlobUtil;
13
- const emitter = DeviceEventEmitter;
14
-
15
- export default class ReactNativeBlobUtilFile {
16
-
17
- }
5
+ export default class ReactNativeBlobUtilFile {}
@@ -3,13 +3,12 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import {
6
- NativeModules,
7
6
  DeviceEventEmitter,
8
7
  NativeAppEventEmitter,
9
8
  } from 'react-native';
10
9
  import UUID from '../utils/uuid';
11
10
 
12
- const ReactNativeBlobUtil = NativeModules.ReactNativeBlobUtil;
11
+ import ReactNativeBlobUtil from "../codegenSpecs/NativeBlobUtils";
13
12
  const emitter = DeviceEventEmitter;
14
13
 
15
14
  export default class ReactNativeBlobUtilReadStream {
@@ -3,12 +3,11 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import {
6
- NativeModules,
7
6
  DeviceEventEmitter,
8
7
  NativeAppEventEmitter,
9
8
  } from 'react-native';
10
9
 
11
- const ReactNativeBlobUtil = NativeModules.ReactNativeBlobUtil;
10
+ import ReactNativeBlobUtil from "../codegenSpecs/NativeBlobUtils";
12
11
 
13
12
  let sessions = {};
14
13
 
@@ -3,13 +3,11 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import {
6
- NativeModules,
7
6
  DeviceEventEmitter,
8
7
  NativeAppEventEmitter,
9
8
  } from 'react-native';
10
9
 
11
- const ReactNativeBlobUtil = NativeModules.ReactNativeBlobUtil;
12
-
10
+ import ReactNativeBlobUtil from "../codegenSpecs/NativeBlobUtils";
13
11
  export default class ReactNativeBlobUtilWriteStream {
14
12
 
15
13
  id : string;