react-native-blob-util 0.19.10 → 0.21.1

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.
@@ -1,4 +1,4 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ReactNativeBlobUtil">
2
2
 
3
3
  <!-- Required to download files from Google Play -->
4
4
  <uses-permission android:name="android.permission.INTERNET" />
@@ -2,7 +2,7 @@ package com.ReactNativeBlobUtil;
2
2
 
3
3
  import androidx.annotation.Nullable;
4
4
 
5
- import com.facebook.react.TurboReactPackage;
5
+ import com.facebook.react.BaseReactPackage;
6
6
  import com.facebook.react.bridge.NativeModule;
7
7
  import com.facebook.react.bridge.ReactApplicationContext;
8
8
  import com.facebook.react.module.model.ReactModuleInfo;
@@ -11,7 +11,7 @@ import com.facebook.react.module.model.ReactModuleInfoProvider;
11
11
  import java.util.HashMap;
12
12
  import java.util.Map;
13
13
 
14
- public class ReactNativeBlobUtilPackage extends TurboReactPackage {
14
+ public class ReactNativeBlobUtilPackage extends BaseReactPackage {
15
15
 
16
16
  @Nullable
17
17
  @Override
@@ -35,7 +35,6 @@ public class ReactNativeBlobUtilPackage extends TurboReactPackage {
35
35
  ReactNativeBlobUtilImpl.NAME,
36
36
  false, // canOverrideExistingModule
37
37
  false, // needsEagerInit
38
- true, // hasConstants
39
38
  false, // isCxxModule
40
39
  isTurboModule // isTurboModule
41
40
  ));
@@ -24,6 +24,7 @@ import androidx.annotation.NonNull;
24
24
  import com.ReactNativeBlobUtil.Response.ReactNativeBlobUtilDefaultResp;
25
25
  import com.ReactNativeBlobUtil.Response.ReactNativeBlobUtilFileResp;
26
26
  import com.ReactNativeBlobUtil.Utils.Tls12SocketFactory;
27
+ import com.ReactNativeBlobUtil.ReactNativeBlobUtilFS;
27
28
  import com.facebook.common.logging.FLog;
28
29
  import com.facebook.react.bridge.Arguments;
29
30
  import com.facebook.react.bridge.Callback;
@@ -32,6 +33,7 @@ import com.facebook.react.bridge.ReadableMap;
32
33
  import com.facebook.react.bridge.ReadableMapKeySetIterator;
33
34
  import com.facebook.react.bridge.WritableArray;
34
35
  import com.facebook.react.bridge.WritableMap;
36
+ import com.facebook.react.bridge.ReactApplicationContext;
35
37
  import com.facebook.react.modules.core.DeviceEventManagerModule;
36
38
 
37
39
  import java.io.File;
@@ -114,6 +116,7 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
114
116
  String url;
115
117
  String rawRequestBody;
116
118
  String destPath;
119
+ String customPath;
117
120
  ReadableArray rawRequestBodyArray;
118
121
  ReadableMap headers;
119
122
  Callback callback;
@@ -234,7 +237,11 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
234
237
 
235
238
  @Override
236
239
  public void run() {
237
-
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);
238
245
  // use download manager instead of default HTTP implementation
239
246
  if (options.addAndroidDownloads != null && options.addAndroidDownloads.hasKey("useDownloadManager")) {
240
247
 
@@ -253,14 +260,51 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
253
260
  req.setDescription(options.addAndroidDownloads.getString("description"));
254
261
  }
255
262
  if (options.addAndroidDownloads.hasKey("path")) {
256
- req.setDestinationUri(Uri.parse("file://" + options.addAndroidDownloads.getString("path")));
263
+ String path = options.addAndroidDownloads.getString("path");
264
+ File f = new File(path);
265
+ File dir = f.getParentFile();
266
+
267
+ if (!f.exists()) {
268
+ if (dir != null && !dir.exists()) {
269
+ if (!dir.mkdirs() && !dir.exists()) {
270
+ invoke_callback( "Failed to create parent directory of '" + path + "'", null, null);
271
+ return;
272
+ }
273
+ }
274
+ }
275
+ req.setDestinationUri(Uri.parse("file://" + path));
276
+
277
+ customPath = path;
278
+ }
279
+
280
+
281
+ if (options.addAndroidDownloads.hasKey("storeLocal") && options.addAndroidDownloads.getBoolean("storeLocal")) {
282
+ RNLog.w(ReactNativeBlobUtilImpl.RCTContext, "a");
283
+ String path = (String) ReactNativeBlobUtilFS.getSystemfolders(ReactNativeBlobUtilImpl.RCTContext).get("DownloadDir");
284
+ path = path + UUID.randomUUID().toString();
285
+
286
+ File f = new File(path);
287
+ File dir = f.getParentFile();
288
+ if (!f.exists()) {
289
+ if (dir != null && !dir.exists()) {
290
+ if (!dir.mkdirs() && !dir.exists()) {
291
+ invoke_callback( "Failed to create parent directory of '" + path + "'", null, null);
292
+ return;
293
+ }
294
+ }
295
+ }
296
+ req.setDestinationUri(Uri.parse("file://" + path));
297
+ customPath = path;
257
298
  }
299
+
258
300
  if (options.addAndroidDownloads.hasKey("mime")) {
259
301
  req.setMimeType(options.addAndroidDownloads.getString("mime"));
260
302
  }
303
+
261
304
  if (options.addAndroidDownloads.hasKey("mediaScannable") && options.addAndroidDownloads.getBoolean("mediaScannable")) {
262
305
  req.allowScanningByMediaScanner();
263
306
  }
307
+
264
308
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && options.addAndroidDownloads.hasKey("storeInDownloads") && options.addAndroidDownloads.getBoolean("storeInDownloads")) {
265
309
  String t = options.addAndroidDownloads.getString("title");
266
310
  if(t == null || t.isEmpty())
@@ -288,7 +332,7 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
288
332
  } catch (MalformedURLException e) {
289
333
  e.printStackTrace();
290
334
  }
291
- Context appCtx = ReactNativeBlobUtilImpl.RCTContext.getApplicationContext();
335
+
292
336
  DownloadManager dm = (DownloadManager) appCtx.getSystemService(Context.DOWNLOAD_SERVICE);
293
337
  downloadManagerId = dm.enqueue(req);
294
338
  androidDownloadManagerTaskTable.put(taskId, Long.valueOf(downloadManagerId));
@@ -296,7 +340,7 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
296
340
  appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED);
297
341
  }else{
298
342
  appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
299
- }
343
+ }
300
344
  future = scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
301
345
  @Override
302
346
  public void run() {
@@ -915,9 +959,9 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
915
959
  }
916
960
 
917
961
  // When the file is not found in media content database, check if custom path exists
918
- if (options.addAndroidDownloads.hasKey("path")) {
962
+ if (options.addAndroidDownloads.hasKey("path") || options.addAndroidDownloads.hasKey("storeLocal")) {
919
963
  try {
920
- String customDest = options.addAndroidDownloads.getString("path");
964
+ String customDest = customPath;
921
965
  boolean exists = new File(customDest).exists();
922
966
  if (!exists)
923
967
  throw new Exception("Download manager download failed, the file does not downloaded to destination.");
package/index.d.ts CHANGED
@@ -448,7 +448,7 @@ export interface FS {
448
448
 
449
449
  dirs: Dirs;
450
450
 
451
- slice(src: string, dest: string, start: number, end: number): Promise<void>;
451
+ slice(src: string, dest: string, start: number, end: number): Promise<string>;
452
452
 
453
453
  asset(path: string): string;
454
454
 
@@ -771,7 +771,7 @@ export interface AddAndroidDownloads {
771
771
  */
772
772
  description?: string;
773
773
  /**
774
- * The destination which the file will be downloaded, it SHOULD be a location on external storage (DCIMDir).
774
+ * The destination which the file will be downloaded, it SHOULD be a location on external storage (DCIMDir). CacheDir and DocumentDir don't work
775
775
  */
776
776
  path?: string;
777
777
  /**
@@ -779,7 +779,7 @@ export interface AddAndroidDownloads {
779
779
  */
780
780
  mime?: string;
781
781
  /**
782
- * A boolean value, see Officail Document
782
+ * A boolean value, see Official Document
783
783
  * (https://developer.android.com/reference/android/app/DownloadManager.html#addCompletedDownload(java.lang.String, java.lang.String, boolean, java.lang.String, java.lang.String, long, boolean))
784
784
  */
785
785
  mediaScannable?: boolean;
@@ -791,6 +791,11 @@ export interface AddAndroidDownloads {
791
791
  * A boolean value decide whether show a notification when download complete.
792
792
  */
793
793
  notification?: boolean;
794
+
795
+ /**
796
+ * If true android download manager will try to save the file to the apps Download direcotry
797
+ */
798
+ storeLocal?: boolean
794
799
  }
795
800
 
796
801
  export interface ReactNativeBlobUtilResponseInfo {
package/index.js.flow CHANGED
@@ -1,190 +1,191 @@
1
1
  // @flow strict
2
2
 
3
3
  declare class AndroidApi {
4
- actionViewIntent(path: string, mime?: string): Promise<void>;
5
- addCompleteDownload(options: AndroidDownloadOption): Promise<void>;
6
- getContentIntent(mime: string): Promise<string>;
7
- getSDCardApplicationDir(): Promise<string>;
8
- getSDCardDir(): Promise<string>;
4
+ actionViewIntent(path: string, mime?: string): Promise<void>;
5
+ addCompleteDownload(options: AndroidDownloadOption): Promise<void>;
6
+ getContentIntent(mime: string): Promise<string>;
7
+ getSDCardApplicationDir(): Promise<string>;
8
+ getSDCardDir(): Promise<string>;
9
9
  }
10
10
 
11
11
  declare class FetchBlobResponse {
12
- data: string;
13
- respInfo: ReactNativeBlobUtilResponseInfo;
14
- taskId: string;
15
- type: "utf8" | "base64" | "path";
16
- array(): Promise<number[]>;
17
- base64(): string | Promise<string>;
18
- blob(): Promise<Blob>;
19
- flush(): Promise<void>;
20
- info(): ReactNativeBlobUtilResponseInfo;
21
- // $FlowExpectedError Not possible to specify in strict mode.
22
- json(): any;
23
- path(): string;
24
- readFile(encoding: Encoding): ?Promise<number[] | string>;
25
- readStream(encoding: Encoding): ?Promise<ReactNativeBlobUtilReadStream>;
26
- session(name: string): ?ReactNativeBlobUtilSession;
27
- text(): string | Promise<string>;
12
+ data: string;
13
+ respInfo: ReactNativeBlobUtilResponseInfo;
14
+ taskId: string;
15
+ type: "utf8" | "base64" | "path";
16
+ array(): Promise<number[]>;
17
+ base64(): string | Promise<string>;
18
+ blob(): Promise<Blob>;
19
+ flush(): Promise<void>;
20
+ info(): ReactNativeBlobUtilResponseInfo;
21
+ // $FlowExpectedError Not possible to specify in strict mode.
22
+ json(): any;
23
+ path(): string;
24
+ readFile(encoding: Encoding): ?Promise<number[] | string>;
25
+ readStream(encoding: Encoding): ?Promise<ReactNativeBlobUtilReadStream>;
26
+ session(name: string): ?ReactNativeBlobUtilSession;
27
+ text(): string | Promise<string>;
28
28
  }
29
29
 
30
30
  declare class FsApi {
31
- ReactNativeBlobUtilSession: ReactNativeBlobUtilSession;
32
- dirs: Dirs;
33
- appendFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;
34
- asset(path: string): string;
35
- cp(path: string, dest: string): Promise<boolean>;
36
- createFile(path: string, data: string, encoding: Encoding | "uri"): Promise<string>;
37
- df(): Promise<AndroidFsStat | IosFsStat>;
38
- exists(path: string): Promise<boolean>;
39
- hash(path: string, algorithm: HashAlgorithm): Promise<string>;
40
- isDir(path: string): Promise<boolean>;
41
- ls(path: string): Promise<string[]>;
42
- lstat(path: string): Promise<ReactNativeBlobUtilStat[]>;
43
- mkdir(path: string): Promise<boolean>;
44
- mv(path: string, dest: string): Promise<boolean>;
45
- pathForAppGroup(groupName: string): Promise<string>;
46
- readFile(path: string, encoding: Encoding, bufferSize?: number): Promise<number[] | string>;
47
- readStream(path: string, encoding: Encoding, bufferSize?: number, tick?: number): Promise<ReactNativeBlobUtilReadStream>;
48
- scanFile(pairs: {mime: string, path: string}[]): Promise<void>;
49
- session(name: string): ReactNativeBlobUtilSession;
50
- slice(src: string, dest: string, start: number, end: number): Promise<string>;
51
- stat(path: string): Promise<ReactNativeBlobUtilStat>;
52
- unlink(path: string): Promise<void>;
53
- writeFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;
54
- writeStream(path: string, encoding: Encoding, append?: boolean): Promise<ReactNativeBlobUtilWriteStream>;
31
+ ReactNativeBlobUtilSession: ReactNativeBlobUtilSession;
32
+ dirs: Dirs;
33
+ appendFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;
34
+ asset(path: string): string;
35
+ cp(path: string, dest: string): Promise<boolean>;
36
+ createFile(path: string, data: string, encoding: Encoding | "uri"): Promise<string>;
37
+ df(): Promise<AndroidFsStat | IosFsStat>;
38
+ exists(path: string): Promise<boolean>;
39
+ hash(path: string, algorithm: HashAlgorithm): Promise<string>;
40
+ isDir(path: string): Promise<boolean>;
41
+ ls(path: string): Promise<string[]>;
42
+ lstat(path: string): Promise<ReactNativeBlobUtilStat[]>;
43
+ mkdir(path: string): Promise<boolean>;
44
+ mv(path: string, dest: string): Promise<boolean>;
45
+ pathForAppGroup(groupName: string): Promise<string>;
46
+ readFile(path: string, encoding: Encoding, bufferSize?: number): Promise<number[] | string>;
47
+ readStream(path: string, encoding: Encoding, bufferSize?: number, tick?: number): Promise<ReactNativeBlobUtilReadStream>;
48
+ scanFile(pairs: { mime: string, path: string }[]): Promise<void>;
49
+ session(name: string): ReactNativeBlobUtilSession;
50
+ slice(src: string, dest: string, start: number, end: number): Promise<string>;
51
+ stat(path: string): Promise<ReactNativeBlobUtilStat>;
52
+ unlink(path: string): Promise<void>;
53
+ writeFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;
54
+ writeStream(path: string, encoding: Encoding, append?: boolean): Promise<ReactNativeBlobUtilWriteStream>;
55
55
  }
56
56
 
57
57
  declare class IosApi {
58
- excludeFromBackupKey(path: string): Promise<void>;
59
- openDocument(path: string, scheme?: string): Promise<void>;
60
- previewDocument(path: string, scheme?: string): Promise<void>;
58
+ excludeFromBackupKey(path: string): Promise<void>;
59
+ openDocument(path: string, scheme?: string): Promise<void>;
60
+ previewDocument(path: string, scheme?: string): Promise<void>;
61
61
  }
62
62
 
63
63
  declare class ReactNativeBlobUtilReadStream {
64
- bufferSize?: number;
65
- closed: boolean;
66
- encoding: Encoding;
67
- path: string;
68
- tick: number;
69
- onData(fn: (chunk: string) => void): void;
70
- onEnd(fn: () => void): void;
71
- onError(fn: (err: Error) => void): void;
72
- open(): void;
64
+ bufferSize?: number;
65
+ closed: boolean;
66
+ encoding: Encoding;
67
+ path: string;
68
+ tick: number;
69
+ onData(fn: (chunk: string) => void): void;
70
+ onEnd(fn: () => void): void;
71
+ onError(fn: (err: Error) => void): void;
72
+ open(): void;
73
73
  }
74
74
 
75
75
  declare class ReactNativeBlobUtilSession {
76
- static getSession(name: string): ReactNativeBlobUtilSession;
77
- static removeSession(name: string): void;
78
- static setSession(name: string, val: ReactNativeBlobUtilSession): void;
76
+ static getSession(name: string): ReactNativeBlobUtilSession;
77
+ static removeSession(name: string): void;
78
+ static setSession(name: string, val: ReactNativeBlobUtilSession): void;
79
79
 
80
- name: string;
81
- add(path: string): ReactNativeBlobUtilSession;
82
- constructor(name: string, list: string[]): ReactNativeBlobUtilSession;
83
- dispose(): Promise<void>;
84
- list(): string[];
85
- remove(path: string): ReactNativeBlobUtilSession;
80
+ name: string;
81
+ add(path: string): ReactNativeBlobUtilSession;
82
+ constructor(name: string, list: string[]): ReactNativeBlobUtilSession;
83
+ dispose(): Promise<void>;
84
+ list(): string[];
85
+ remove(path: string): ReactNativeBlobUtilSession;
86
86
  }
87
87
 
88
88
  declare class ReactNativeBlobUtilWriteStream {
89
- append: boolean;
90
- encoding: string;
91
- id: string;
92
- close(): void;
93
- write(data: string): Promise<void>;
89
+ append: boolean;
90
+ encoding: string;
91
+ id: string;
92
+ close(): void;
93
+ write(data: string): Promise<void>;
94
94
  }
95
95
 
96
96
  declare class ReactNativeBlobUtil {
97
- android: AndroidApi;
98
- base64: {+decode: (input: string) => string, +encode: (input: string) => string};
99
- fs: FsApi;
100
- ios: IosApi;
101
- config(options: ReactNativeBlobUtilConfig): {fetch: (method: Methods, url: string, headers?: {[key: string]: string}, body?: string | FormField[]) => StatefulPromise<FetchBlobResponse>};
102
- fetch(method: Methods, url: string, headers?: {[key: string]: string}, body?: string | FormField[]): StatefulPromise<FetchBlobResponse>;
103
- session(name: string): ReactNativeBlobUtilSession;
104
- wrap(path: string): string;
97
+ android: AndroidApi;
98
+ base64: { +decode: (input: string) => string, +encode: (input: string) => string };
99
+ fs: FsApi;
100
+ ios: IosApi;
101
+ config(options: ReactNativeBlobUtilConfig): { fetch: (method: Methods, url: string, headers?: { [key: string]: string }, body?: string | FormField[]) => StatefulPromise<FetchBlobResponse> };
102
+ fetch(method: Methods, url: string, headers?: { [key: string]: string }, body?: string | FormField[]): StatefulPromise<FetchBlobResponse>;
103
+ session(name: string): ReactNativeBlobUtilSession;
104
+ wrap(path: string): string;
105
105
  }
106
106
 
107
107
  declare class StatefulPromise<T> extends Promise<T> {
108
- cancel(callback?: (error: ?string, taskId: ?string) => void): void;
109
- expire(callback: () => void): StatefulPromise<void>;
110
- progress(config: {count?: number, interval?: number} | ProgressCallback, callback?: ProgressCallback): StatefulPromise<T>;
111
- stateChange(callback: (state: ReactNativeBlobUtilResponseInfo) => void): StatefulPromise<T>;
112
- uploadProgress(config: {count?: number, interval?: number} | UploadProgressCallback, callback?: UploadProgressCallback): StatefulPromise<T>;
108
+ cancel(callback?: (error: ?string, taskId: ?string) => void): void;
109
+ expire(callback: () => void): StatefulPromise<void>;
110
+ progress(config: { count?: number, interval?: number } | ProgressCallback, callback?: ProgressCallback): StatefulPromise<T>;
111
+ stateChange(callback: (state: ReactNativeBlobUtilResponseInfo) => void): StatefulPromise<T>;
112
+ uploadProgress(config: { count?: number, interval?: number } | UploadProgressCallback, callback?: UploadProgressCallback): StatefulPromise<T>;
113
113
  }
114
114
 
115
115
  export type AddAndroidDownloads = {
116
- description?: string,
117
- mediaScannable?: boolean,
118
- mime?: string,
119
- notification?: boolean,
120
- path?: string,
121
- title?: string,
122
- useDownloadManager?: boolean
116
+ description?: string,
117
+ mediaScannable?: boolean,
118
+ mime?: string,
119
+ notification?: boolean,
120
+ path?: string,
121
+ title?: string,
122
+ useDownloadManager?: boolean,
123
+ storeLocal: boolean
123
124
  };
124
125
  export type AndroidDownloadOption = {
125
- description?: string,
126
- mime?: string,
127
- path: string,
128
- showNotification?: boolean,
129
- title?: string
126
+ description?: string,
127
+ mime?: string,
128
+ path: string,
129
+ showNotification?: boolean,
130
+ title?: string
130
131
  };
131
132
  export type AndroidFsStat = {
132
- external_free: number,
133
- external_total: number,
134
- internal_free: number,
135
- internal_total: number
133
+ external_free: number,
134
+ external_total: number,
135
+ internal_free: number,
136
+ internal_total: number
136
137
  };
137
138
  export type Dirs = {
138
- CacheDir: string,
139
- DCIMDir: string,
140
- DocumentDir: string,
141
- DownloadDir: string,
142
- LibraryDir: string,
143
- MainBundleDir: string,
144
- MovieDir: string,
145
- MusicDir: string,
146
- PictureDir: string,
147
- SDCardApplicationDir: string,
148
- SDCardDir: string
139
+ CacheDir: string,
140
+ DCIMDir: string,
141
+ DocumentDir: string,
142
+ DownloadDir: string,
143
+ LibraryDir: string,
144
+ MainBundleDir: string,
145
+ MovieDir: string,
146
+ MusicDir: string,
147
+ PictureDir: string,
148
+ SDCardApplicationDir: string,
149
+ SDCardDir: string
149
150
  };
150
151
  export type Encoding = "utf8" | "ascii" | "base64";
151
- export type FormField = {data: string, filename?: string, name: string, type?: string};
152
+ export type FormField = { data: string, filename?: string, name: string, type?: string };
152
153
  export type HashAlgorithm = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512";
153
- export type IosFsStat = {free: number, total: number};
154
+ export type IosFsStat = { free: number, total: number };
154
155
  export type Methods = "POST" | "GET" | "DELETE" | "PUT" | "post" | "get" | "delete" | "put";
155
156
  export type ProgressCallback = (received: number, total: number) => void;
156
157
  export type ReactNativeBlobUtilConfig = {
157
- Progress?: { count?: number, interval?: number },
158
- UploadProgress?: { count?: number, interval?: number },
159
- IOSBackgroundTask?: boolean,
160
- addAndroidDownloads?: AddAndroidDownloads,
161
- appendExt?: string,
162
- fileCache?: boolean,
163
- indicator?: boolean,
164
- overwrite?: boolean,
165
- path?: string,
166
- session?: string,
167
- timeout?: number,
168
- trusty?: boolean,
169
- wifiOnly?: boolean,
170
- followRedirect?: boolean
158
+ Progress?: { count?: number, interval?: number },
159
+ UploadProgress?: { count?: number, interval?: number },
160
+ IOSBackgroundTask?: boolean,
161
+ addAndroidDownloads?: AddAndroidDownloads,
162
+ appendExt?: string,
163
+ fileCache?: boolean,
164
+ indicator?: boolean,
165
+ overwrite?: boolean,
166
+ path?: string,
167
+ session?: string,
168
+ timeout?: number,
169
+ trusty?: boolean,
170
+ wifiOnly?: boolean,
171
+ followRedirect?: boolean
171
172
  };
172
173
  export type ReactNativeBlobUtilResponseInfo = {
173
- headers: {[fieldName: string]: string},
174
- redirects: string[],
175
- respType: "text" | "blob" | "" | "json",
176
- rnfbEncode: "path" | Encoding,
177
- state: string,
178
- status: number,
179
- taskId: string,
180
- timeout: boolean
174
+ headers: { [fieldName: string]: string },
175
+ redirects: string[],
176
+ respType: "text" | "blob" | "" | "json",
177
+ rnfbEncode: "path" | Encoding,
178
+ state: string,
179
+ status: number,
180
+ taskId: string,
181
+ timeout: boolean
181
182
  };
182
183
  export type ReactNativeBlobUtilStat = {
183
- filename: string,
184
- lastModified: number,
185
- path: string,
186
- size: number,
187
- type: "directory" | "file" | "asset"
184
+ filename: string,
185
+ lastModified: number,
186
+ path: string,
187
+ size: number,
188
+ type: "directory" | "file" | "asset"
188
189
  };
189
190
  export type UploadProgressCallback = (sent: number, total: number) => void;
190
191
 
@@ -124,7 +124,7 @@ typedef NS_ENUM(NSUInteger, ResponseFormat) {
124
124
  defaultConfigObject.timeoutIntervalForRequest = timeout/1000;
125
125
  }
126
126
 
127
- if([options valueForKey:CONFIG_WIFI_ONLY] != nil && ![options[CONFIG_WIFI_ONLY] boolValue]){
127
+ if([options valueForKey:CONFIG_WIFI_ONLY] != nil && [options[CONFIG_WIFI_ONLY] boolValue]){
128
128
  [defaultConfigObject setAllowsCellularAccess:NO];
129
129
  }
130
130
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-blob-util",
3
- "version": "0.19.10",
3
+ "version": "0.21.1",
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": {
package/types.js CHANGED
@@ -2,16 +2,16 @@
2
2
  export type ReactNativeBlobUtilConfig = {
3
3
  Progress: any,
4
4
  UploadProgress: any,
5
- fileCache : bool,
5
+ fileCache : boolean,
6
6
  transformFile: boolean;
7
7
  path : string,
8
8
  appendExt : string,
9
9
  session : string,
10
10
  addAndroidDownloads : any,
11
- indicator : bool,
12
- followRedirect : bool,
13
- trusty : bool,
14
- wifiOnly : bool
11
+ indicator : boolean,
12
+ followRedirect : boolean,
13
+ trusty : boolean,
14
+ wifiOnly : boolean
15
15
  };
16
16
 
17
17
  export type ReactNativeBlobUtilNative = {