@hxa-rn/rn-fetch-blob 0.12.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 (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +290 -0
  3. package/harmony/fetch_blob/LICENSE +21 -0
  4. package/harmony/fetch_blob/NOTICE +33 -0
  5. package/harmony/fetch_blob/OAT.xml +38 -0
  6. package/harmony/fetch_blob/build-profile.json5 +16 -0
  7. package/harmony/fetch_blob/hvigorfile.ts +2 -0
  8. package/harmony/fetch_blob/index.ets +1 -0
  9. package/harmony/fetch_blob/oh-package.json5 +14 -0
  10. package/harmony/fetch_blob/src/main/cpp/CMakeLists.txt +15 -0
  11. package/harmony/fetch_blob/src/main/cpp/FetchBlobPackage.h +13 -0
  12. package/harmony/fetch_blob/src/main/cpp/generated/RNOH/generated/BaseFetchBlobPackage.h +72 -0
  13. package/harmony/fetch_blob/src/main/cpp/generated/RNOH/generated/turbo_modules/RNFetchBlob.cpp +55 -0
  14. package/harmony/fetch_blob/src/main/cpp/generated/RNOH/generated/turbo_modules/RNFetchBlob.h +16 -0
  15. package/harmony/fetch_blob/src/main/ets/FetchBlobTurboModulesFactory.ets +18 -0
  16. package/harmony/fetch_blob/src/main/ets/Logger.ts +40 -0
  17. package/harmony/fetch_blob/src/main/ets/RNFetchBlobConfig.ts +45 -0
  18. package/harmony/fetch_blob/src/main/ets/RNFetchBlobFS.ts +673 -0
  19. package/harmony/fetch_blob/src/main/ets/RNFetchBlobImpl.ts +246 -0
  20. package/harmony/fetch_blob/src/main/ets/RNFetchBlobReq.ts +530 -0
  21. package/harmony/fetch_blob/src/main/ets/RNFetchBlobStream.ts +169 -0
  22. package/harmony/fetch_blob/src/main/ets/RNFetchBlobTurboModule.ts +192 -0
  23. package/harmony/fetch_blob/src/main/ets/generated/index.ets +5 -0
  24. package/harmony/fetch_blob/src/main/ets/generated/ts.ts +5 -0
  25. package/harmony/fetch_blob/src/main/ets/generated/turboModules/RNFetchBlob.ts +92 -0
  26. package/harmony/fetch_blob/src/main/ets/generated/turboModules/ts.ts +5 -0
  27. package/harmony/fetch_blob/src/main/module.json5 +22 -0
  28. package/harmony/fetch_blob/src/main/resources/base/element/string.json +8 -0
  29. package/harmony/fetch_blob/src/main/resources/en_US/element/string.json +8 -0
  30. package/harmony/fetch_blob/src/main/resources/zh_CN/element/string.json +8 -0
  31. package/harmony/fetch_blob.har +0 -0
  32. package/package.json +59 -0
  33. package/src/android.js +62 -0
  34. package/src/class/RNFetchBlobFile.js +17 -0
  35. package/src/class/RNFetchBlobReadStream.js +82 -0
  36. package/src/class/RNFetchBlobSession.js +74 -0
  37. package/src/class/RNFetchBlobWriteStream.js +57 -0
  38. package/src/class/StatefulPromise.js +7 -0
  39. package/src/fs.js +432 -0
  40. package/src/index.d.ts +690 -0
  41. package/src/index.js +577 -0
  42. package/src/ios.js +54 -0
  43. package/src/json-stream.js +45 -0
  44. package/src/lib/oboe-browser.min.js +1 -0
  45. package/src/polyfill/Blob.js +362 -0
  46. package/src/polyfill/Event.js +11 -0
  47. package/src/polyfill/EventTarget.js +79 -0
  48. package/src/polyfill/Fetch.js +213 -0
  49. package/src/polyfill/File.js +27 -0
  50. package/src/polyfill/FileReader.js +90 -0
  51. package/src/polyfill/ProgressEvent.js +32 -0
  52. package/src/polyfill/XMLHttpRequest.js +446 -0
  53. package/src/polyfill/XMLHttpRequestEventTarget.js +118 -0
  54. package/src/polyfill/index.js +11 -0
  55. package/src/specs/v1/NativeRNFetchBlob.ts +85 -0
  56. package/src/types.js +64 -0
  57. package/src/utils/log.js +40 -0
  58. package/src/utils/unicode.js +7 -0
  59. package/src/utils/uri.js +28 -0
  60. package/src/utils/uuid.js +4 -0
package/src/index.d.ts ADDED
@@ -0,0 +1,690 @@
1
+ // Type definitions for react-native-fetch-blob 0.10
2
+ // Project: https://github.com/wkh237/react-native-fetch-blob#readme
3
+ // Definitions by: MNB <https://github.com/MNBuyskih>
4
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
+
6
+ export const RNFetchBlob: RNFetchBlobStatic;
7
+ export type RNFetchBlob = RNFetchBlobStatic;
8
+ export default RNFetchBlob;
9
+
10
+ interface RNFetchBlobStatic {
11
+ fetch(method: Methods, url: string, headers?: { [key: string]: string }, body?: any
12
+ | null): StatefulPromise<FetchBlobResponse>;
13
+ base64: { encode(input: string): string; decode(input: string): string };
14
+ android: AndroidApi;
15
+ ios: IOSApi;
16
+ config(options: RNFetchBlobConfig): RNFetchBlobStatic;
17
+ session(name: string): RNFetchBlobSession;
18
+ fs: FS;
19
+ wrap(path: string): string;
20
+ net: Net;
21
+ polyfill: Polyfill;
22
+ // this require external module https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/oboe
23
+ JSONStream: any;
24
+ }
25
+
26
+ export interface Polyfill {
27
+ Blob: PolyfillBlob;
28
+ File: PolyfillFile;
29
+ XMLHttpRequest: PolyfillXMLHttpRequest;
30
+ ProgressEvent: PolyfillProgressEvent;
31
+ Event: PolyfillEvent;
32
+ FileReader: PolyfillFileReader;
33
+ Fetch: PolyfillFetch;
34
+ }
35
+
36
+ export declare class PolyfillFetch extends RNFetchBlobFetchPolyfill {
37
+ constructor(config: RNFetchBlobConfig);
38
+ }
39
+
40
+ export declare class RNFetchBlobFetchPolyfill {
41
+ constructor(config: RNFetchBlobConfig);
42
+
43
+ build(): (url: string, options: RNFetchBlobConfig) => StatefulPromise<RNFetchBlobFetchRepsonse>;
44
+ }
45
+
46
+ export interface RNFetchBlobFetchRepsonse {
47
+ arrayBuffer(): Promise<any[]>;
48
+ blob(): Promise<PolyfillBlob>;
49
+ json(): Promise<any>;
50
+ rawResp(): Promise<FetchBlobResponse>;
51
+ text(): Promise<string>;
52
+ bodyUsed: boolean;
53
+ headers: any;
54
+ ok: boolean;
55
+ resp: FetchBlobResponse;
56
+ rnfbResp: FetchBlobResponse;
57
+ rnfbRespInfo: RNFetchBlobResponseInfo;
58
+ status: number;
59
+ type: string;
60
+ }
61
+
62
+ /**
63
+ * RNFetchBlob response object class.
64
+ */
65
+ export interface FetchBlobResponse {
66
+ taskId: string;
67
+ /**
68
+ * get path of response temp file
69
+ * @return File path of temp file.
70
+ */
71
+ path(): string;
72
+ type: "base64" | "path" | "utf8";
73
+ data: any;
74
+ /**
75
+ * Convert result to javascript RNFetchBlob object.
76
+ * @return Return a promise resolves Blob object.
77
+ */
78
+ blob(contentType: string, sliceSize: number): Promise<PolyfillBlob>;
79
+ /**
80
+ * Convert result to text.
81
+ * @return Decoded base64 string.
82
+ */
83
+ text(): string | Promise<any>;
84
+ /**
85
+ * Convert result to JSON object.
86
+ * @return Parsed javascript object.
87
+ */
88
+ json(): any;
89
+ /**
90
+ * Return BASE64 string directly.
91
+ * @return BASE64 string of response body.
92
+ */
93
+ base64(): any;
94
+ /**
95
+ * Remove cahced file
96
+ */
97
+ flush(): void;
98
+ respInfo: RNFetchBlobResponseInfo;
99
+ info(): RNFetchBlobResponseInfo;
100
+ session(name: string): RNFetchBlobSession | null;
101
+ /**
102
+ * Read file content with given encoding, if the response does not contains
103
+ * a file path, show warning message
104
+ * @param encode Encode type, should be one of `base64`, `ascrii`, `utf8`.
105
+ */
106
+ readFile(encode: Encoding): Promise<any> | null;
107
+ /**
108
+ * Start read stream from cached file
109
+ * @param encode Encode type, should be one of `base64`, `ascrii`, `utf8`.
110
+ */
111
+ readStream(encode: Encoding): RNFetchBlobStream | null;
112
+ }
113
+
114
+ export interface PolyfillFileReader extends EventTarget {
115
+ isRNFBPolyFill: boolean;
116
+ onloadstart(e: Event): void;
117
+ onprogress(e: Event): void;
118
+ onload(e: Event): void;
119
+ onabort(e: Event): void;
120
+ onerror(e: Event): void;
121
+ onloadend(e: Event): void;
122
+
123
+ abort(): void;
124
+ readAsArrayBuffer(b: PolyfillBlob): void;
125
+ readAsBinaryString(b: PolyfillBlob): void;
126
+ readAsText(b: PolyfillBlob, label?: string): void;
127
+ readAsDataURL(b: PolyfillBlob): void;
128
+
129
+ readyState: number;
130
+ result: number;
131
+ }
132
+
133
+ export declare namespace PolyfillFileReader {
134
+ const EMPTY: number;
135
+ const LOADING: number;
136
+ const DONE: number;
137
+ }
138
+
139
+ export declare class PolyfillEvent {
140
+ }
141
+
142
+ export interface PolyfillProgressEvent extends EventTarget {
143
+ lengthComputable: boolean;
144
+ loaded: number;
145
+ total: number;
146
+ }
147
+
148
+ export declare class PolyfillBlob implements EventTarget {
149
+ /**
150
+ * RNFetchBlob Blob polyfill, create a Blob directly from file path, BASE64
151
+ * encoded data, and string. The conversion is done implicitly according to
152
+ * given `mime`. However, the blob creation is asynchronously, to register
153
+ * event `onCreated` is need to ensure the Blob is creadted.
154
+ *
155
+ * @param data Content of Blob object
156
+ * @param cType Content type settings of Blob object, `text/plain` by default
157
+ * @param defer When this argument set to `true`, blob constructor will not invoke blob created event automatically.
158
+ */
159
+ constructor(data: any, cType: any, defer: boolean);
160
+
161
+ /**
162
+ * Since Blob content will asynchronously write to a file during creation,
163
+ * use this method to register an event handler for Blob initialized event.
164
+ * @param fn An event handler invoked when Blob created
165
+ * @return The Blob object instance itself
166
+ */
167
+ onCreated(fn: () => void): PolyfillBlob;
168
+
169
+ markAsDerived(): void;
170
+
171
+ /**
172
+ * Get file reference of the Blob object.
173
+ * @return Blob file reference which can be consumed by RNFetchBlob fs
174
+ */
175
+ getRNFetchBlobRef(): string;
176
+
177
+ /**
178
+ * Create a Blob object which is sliced from current object
179
+ * @param start Start byte number
180
+ * @param end End byte number
181
+ * @param contentType Optional, content type of new Blob object
182
+ */
183
+ slice(start?: number, end?: number, contentType?: string): PolyfillBlob;
184
+
185
+ /**
186
+ * Read data of the Blob object, this is not standard method.
187
+ * @param encoding Read data with encoding
188
+ */
189
+ readBlob(encoding: string): Promise<any>;
190
+
191
+ /**
192
+ * Release the resource of the Blob object.
193
+ * @nonstandard
194
+ */
195
+ close(): Promise<void>;
196
+ }
197
+
198
+ export declare namespace PolyfillBlob {
199
+ function clearCache(): void;
200
+
201
+ function build(data: any, cType: any): Promise<PolyfillBlob>;
202
+
203
+ function setLog(level: number): void;
204
+ }
205
+
206
+ export declare class PolyfillFile extends PolyfillBlob {
207
+ }
208
+
209
+ export interface PolyfillXMLHttpRequest extends PolyfillXMLHttpRequestEventTarget {
210
+ upload: PolyfillXMLHttpRequestEventTarget;
211
+ readonly UNSENT: number;
212
+ readonly OPENED: number;
213
+ readonly HEADERS_RECEIVED: number;
214
+ readonly LOADING: number;
215
+ readonly DONE: number;
216
+
217
+ /**
218
+ * XMLHttpRequest.open, always async, user and password not supported. When
219
+ * this method invoked, headers should becomes empty again.
220
+ * @param method Request method
221
+ * @param url Request URL
222
+ * @param async Always async
223
+ * @param user NOT SUPPORTED
224
+ * @param password NOT SUPPORTED
225
+ */
226
+ open(method: string, url: string, async: true, user: any, password: any): void;
227
+
228
+ /**
229
+ * Invoke this function to send HTTP request, and set body.
230
+ * @param body Body in RNfetchblob flavor
231
+ */
232
+ send(body: any): void;
233
+
234
+ overrideMimeType(mime: string): void;
235
+
236
+ setRequestHeader(name: string, value: string): void;
237
+
238
+ abort(): void;
239
+
240
+ getResponseHeader(field: string): string | null;
241
+
242
+ getAllResponseHeaders(): string | null;
243
+
244
+ onreadystatechange(e: Event): void;
245
+ readyState: number;
246
+ status: number;
247
+ statusText: string;
248
+ response: any;
249
+ responseText: any;
250
+ responseURL: string;
251
+ responseHeaders: any;
252
+ timeout: number;
253
+ responseType: string;
254
+ }
255
+
256
+ export declare namespace PolyfillXMLHttpRequest {
257
+ const binaryContentTypes: string[];
258
+ const UNSENT: number;
259
+ const OPENED: number;
260
+ const HEADERS_RECEIVED: number;
261
+ const LOADING: number;
262
+ const DONE: number;
263
+
264
+ function setLog(level: number): void;
265
+
266
+ function addBinaryContentType(substr: string): void;
267
+
268
+ function removeBinaryContentType(): void;
269
+ }
270
+
271
+ export interface PolyfillXMLHttpRequestEventTarget extends EventTarget {
272
+ onabort(e: Event): void;
273
+ onerror(e: Event): void;
274
+ onload(e: Event): void;
275
+ onloadstart(e: Event): void;
276
+ onprogress(e: Event): void;
277
+ ontimeout(e: Event): void;
278
+ onloadend(e: Event): void;
279
+ }
280
+
281
+ export interface Net {
282
+ /**
283
+ * Get cookie according to the given url.
284
+ * @param domain Domain of the cookies to be removed, remove all
285
+ * @return Cookies of a specific domain.
286
+ */
287
+ getCookies(domain: string): Promise<string[]>;
288
+
289
+ /**
290
+ * Remove cookies for a specific domain
291
+ * @param domain Domain of the cookies to be removed, remove all
292
+ * cookies when this is null.
293
+ */
294
+ removeCookies(domain?: string): Promise<null>;
295
+ }
296
+
297
+ type HashAlgorithm = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512";
298
+ export interface FS {
299
+ RNFetchBlobSession: RNFetchBlobSession;
300
+
301
+ /**
302
+ * Remove file at path.
303
+ * @param path:string Path of target file.
304
+ */
305
+ unlink(path: string): Promise<void>;
306
+
307
+ /**
308
+ * Create a directory.
309
+ * @param path Path of directory to be created
310
+ */
311
+ mkdir(path: string): Promise<void>;
312
+
313
+ /**
314
+ * Get a file cache session
315
+ * @param name Stream ID
316
+ */
317
+ session(name: string): RNFetchBlobSession;
318
+
319
+ ls(path: string): Promise<string[]>;
320
+
321
+ /**
322
+ * Read the file from the given path and calculate a cryptographic hash sum over its contents.
323
+ *
324
+ * @param path Path to the file
325
+ * @param algorithm The hash algorithm to use
326
+ */
327
+ hash(path: string, algorithm: HashAlgorithm): Promise<string>;
328
+
329
+ /**
330
+ * Create file stream from file at `path`.
331
+ * @param path The file path.
332
+ * @param encoding Data encoding, should be one of `base64`, `utf8`, `ascii`
333
+ * @param bufferSize Size of stream buffer.
334
+ * @return RNFetchBlobStream stream instance.
335
+ */
336
+ readStream(path: string, encoding: Encoding, bufferSize?: number, tick?: number): Promise<RNFetchBlobReadStream>;
337
+
338
+ mv(path: string, dest: string): Promise<boolean>;
339
+
340
+ cp(path: string, dest: string): Promise<boolean>;
341
+
342
+ /**
343
+ * Create write stream to a file.
344
+ * @param path Target path of file stream.
345
+ * @param encoding Encoding of input data.
346
+ * @param append A flag represent if data append to existing ones.
347
+ * @return A promise resolves a `WriteStream` object.
348
+ */
349
+ writeStream(path: string, encoding: Encoding, append?: boolean): Promise<RNFetchBlobWriteStream>;
350
+
351
+ /**
352
+ * Write data to file.
353
+ * @param path Path of the file.
354
+ * @param data Data to write to the file.
355
+ * @param encoding Encoding of data (Optional).
356
+ */
357
+ writeFile(path: string, data: string | number[], encoding?: Encoding): Promise<void>;
358
+
359
+ appendFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;
360
+
361
+ /**
362
+ * Wrapper method of readStream.
363
+ * @param path Path of the file.
364
+ * @param encoding Encoding of read stream.
365
+ */
366
+ readFile(path: string, encoding: Encoding, bufferSize?: number): Promise<any>;
367
+ /**
368
+ * Check if file exists and if it is a folder.
369
+ * @param path Path to check
370
+ */
371
+ exists(path: string): Promise<boolean>;
372
+
373
+ createFile(path: string, data: string, encoding: Encoding): Promise<void>;
374
+
375
+ isDir(path: string): Promise<boolean>;
376
+
377
+ /**
378
+ * Show statistic data of a path.
379
+ * @param path Target path
380
+ */
381
+ stat(path: string): Promise<RNFetchBlobStat>;
382
+
383
+ lstat(path: string): Promise<RNFetchBlobStat[]>;
384
+
385
+ /**
386
+ * Android only method, request media scanner to scan the file.
387
+ * @param pairs Array contains Key value pairs with key `path` and `mime`.
388
+ */
389
+ scanFile(pairs: Array<{ [key: string]: string }>): Promise<void>;
390
+
391
+ dirs: Dirs;
392
+
393
+ slice(src: string, dest: string, start: number, end: number): Promise<void>;
394
+ asset(path: string): string;
395
+ df(): Promise<{ free: number, total: number }>;
396
+ }
397
+
398
+ export interface Dirs {
399
+ DocumentDir: string;
400
+ CacheDir: string;
401
+ PictureDir: string;
402
+ LibraryDir: string;
403
+ MusicDir: string;
404
+ MovieDir: string;
405
+ DownloadDir: string;
406
+ DCIMDir: string;
407
+ SDCardDir: string;
408
+ MainBundleDir: string;
409
+ }
410
+
411
+ export interface RNFetchBlobWriteStream {
412
+ id: string;
413
+ encoding: string;
414
+ append: boolean;
415
+
416
+ write(data: string): Promise<void>;
417
+ close(): void;
418
+ }
419
+
420
+ export interface RNFetchBlobReadStream {
421
+ path: string;
422
+ encoding: Encoding;
423
+ bufferSize?: number;
424
+ closed: boolean;
425
+ tick: number;
426
+
427
+ open(): void;
428
+
429
+ onData(fn: (chunk: string | number[]) => void): void;
430
+
431
+ onError(fn: (err: any) => void): void;
432
+
433
+ onEnd(fn: () => void): void;
434
+ }
435
+
436
+ export type Encoding = "utf8" | "ascii" | "base64";
437
+
438
+ /* tslint:disable-next-line interface-name*/
439
+ export interface IOSApi {
440
+ /**
441
+ * Open a file in {@link https://developer.apple.com/reference/uikit/uidocumentinteractioncontroller UIDocumentInteractionController},
442
+ * this is the default document viewer of iOS, supports several kinds of files. On Android, there's an similar method {@link android.actionViewIntent}.
443
+ * @param path This is a required field, the path to the document. The path should NOT contains any scheme prefix.
444
+ */
445
+ previewDocument(path: string): void;
446
+
447
+ /**
448
+ * Show options menu for interact with the file.
449
+ * @param path This is a required field, the path to the document. The path should NOT contains any scheme prefix.
450
+ */
451
+ openDocument(path: string): void;
452
+ }
453
+
454
+ export interface AndroidDownloadOption {
455
+ /**
456
+ * Title string to be displayed when the file added to Downloads app.
457
+ */
458
+ title: string
459
+
460
+ /**
461
+ * File description to be displayed when the file added to Downloads app.
462
+ */
463
+ description: string
464
+
465
+ /**
466
+ * MIME string of the file.
467
+ */
468
+ mime: string
469
+
470
+ /**
471
+ * URI string of the file.
472
+ */
473
+ path: string
474
+
475
+ /**
476
+ * Boolean value that determines if notification will be displayed.
477
+ */
478
+ showNotification: boolean
479
+ }
480
+
481
+ export interface AndroidApi {
482
+ /**
483
+ * When sending an ACTION_VIEW intent with given file path and MIME type, system will try to open an
484
+ * App to handle the file. For example, open Gallery app to view an image, or install APK.
485
+ * @param path Path of the file to be opened.
486
+ * @param mime Basically system will open an app according to this MIME type.
487
+ */
488
+ actionViewIntent(path: string, mime: string): Promise<any>;
489
+
490
+ /**
491
+ *
492
+ * This method brings up OS default file picker and resolves a file URI when the user selected a file.
493
+ * However, it does not resolve or reject when user dismiss the file picker via pressing hardware back button,
494
+ * but you can still handle this behavior via AppState.
495
+ * @param mime MIME type filter, only the files matches the MIME will be shown.
496
+ */
497
+ getContentIntent(mime: string): Promise<any>;
498
+
499
+ /**
500
+ * Using this function to add an existing file to Downloads app.
501
+ * @param options An object that for setting the title, description, mime, and notification of the item.
502
+ */
503
+ addCompleteDownload(options: AndroidDownloadOption): Promise<void>;
504
+
505
+ getSDCardDir(): Promise<string>;
506
+
507
+ getSDCardApplicationDir(): Promise<string>;
508
+ }
509
+
510
+ type Methods = "POST" | "GET" | "DELETE" | "PUT" | "post" | "get" | "delete" | "put";
511
+
512
+ /**
513
+ * A declare class inherits Promise, it has extra method like progress, uploadProgress,
514
+ * and cancel which can help managing an asynchronous task's state.
515
+ */
516
+ export interface StatefulPromise<T> extends Promise<T> {
517
+ /**
518
+ * Cancel the request when invoke this method.
519
+ */
520
+ cancel(cb?: (reason: any) => void): StatefulPromise<FetchBlobResponse>;
521
+
522
+ /**
523
+ * Add an event listener which triggers when data receiving from server.
524
+ */
525
+ progress(callback: (received: number, total: number) => void): StatefulPromise<FetchBlobResponse>;
526
+
527
+ /**
528
+ * Add an event listener with custom configuration
529
+ */
530
+ progress(config: { count?: number, interval?: number }, callback: (received: number, total: number) => void): StatefulPromise<FetchBlobResponse>;
531
+
532
+ /**
533
+ * Add an event listener with custom configuration.
534
+ */
535
+ uploadProgress(callback: (sent: number, total: number) => void): StatefulPromise<FetchBlobResponse>;
536
+
537
+ /**
538
+ * Add an event listener with custom configuration
539
+ */
540
+ uploadProgress(config: { count?: number, interval?: number }, callback: (sent: number, total: number) => void): StatefulPromise<FetchBlobResponse>;
541
+
542
+ /**
543
+ * An IOS only API, when IOS app turns into background network tasks will be terminated after ~180 seconds,
544
+ * in order to handle these expired tasks, you can register an event handler, which will be called after the
545
+ * app become active.
546
+ */
547
+ expire(callback: () => void): StatefulPromise<void>;
548
+ }
549
+
550
+ export declare class RNFetchBlobSession {
551
+ constructor(name: string, list: string[]);
552
+
553
+ add(path: string): RNFetchBlobSession;
554
+
555
+ remove(path: string): RNFetchBlobSession;
556
+
557
+ dispose(): Promise<void>;
558
+
559
+ list(): string[];
560
+
561
+ name: string;
562
+
563
+ static getSession(name: string): any;
564
+
565
+ static setSession(name: string): void;
566
+
567
+ static removeSession(name: string): void;
568
+ }
569
+
570
+ /**
571
+ * A set of configurations that will be injected into a fetch method, with the following properties.
572
+ */
573
+ export interface RNFetchBlobConfig {
574
+ /**
575
+ * When this property is true, the downloaded data will overwrite the existing file. (true by default)
576
+ */
577
+ overwrite?: boolean;
578
+
579
+ /**
580
+ * Set timeout of the request (in milliseconds).
581
+ */
582
+ timeout?: number;
583
+
584
+ /**
585
+ * Set this property to true to display a network indicator on status bar, this feature is only supported on IOS.
586
+ */
587
+ indicator?: boolean;
588
+
589
+ /**
590
+ * Set this property to true will allow the request create connection with server have self-signed SSL
591
+ * certification. This is not recommended to use in production.
592
+ */
593
+ trusty?: boolean;
594
+
595
+ /**
596
+ * Set this property to true will only do requests through the WiFi interface, and fail otherwise.
597
+ */
598
+ wifiOnly?: boolean;
599
+
600
+ /**
601
+ * Set this property so redirects are not automatically followed.
602
+ */
603
+ followRedirect?: boolean;
604
+
605
+ /**
606
+ * Set this property to true will makes response data of the fetch stored in a temp file, by default the temp
607
+ * file will stored in App's own root folder with file name template RNFetchBlob_tmp${timestamp}.
608
+ */
609
+ fileCache?: boolean;
610
+
611
+ /**
612
+ * Set this property to change temp file extension that created by fetch response data.
613
+ */
614
+ appendExt?: string;
615
+
616
+ /**
617
+ * When this property has value, fetch API will try to store response data in the path ignoring fileCache and
618
+ * appendExt property.
619
+ */
620
+ path?: string;
621
+
622
+ session?: string;
623
+
624
+ addAndroidDownloads?: AddAndroidDownloads;
625
+
626
+ /**
627
+ * Fix IOS request timeout issue #368 by change default request setting to defaultSessionConfiguration, and make backgroundSessionConfigurationWithIdentifier optional
628
+ */
629
+ IOSBackgroundTask?: boolean;
630
+ }
631
+
632
+ export interface AddAndroidDownloads {
633
+ /**
634
+ * download file using Android download manager or not.
635
+ */
636
+ useDownloadManager?: boolean;
637
+ /**
638
+ * title of the file
639
+ */
640
+ title?: string;
641
+ /**
642
+ * File description of the file.
643
+ */
644
+ description?: string;
645
+ /**
646
+ * The destination which the file will be downloaded, it SHOULD be a location on external storage (DCIMDir).
647
+ */
648
+ path?: string;
649
+ /**
650
+ * MIME type of the file. By default is text/plain
651
+ */
652
+ mime?: string;
653
+ /**
654
+ * A boolean value, see Officail Document
655
+ * (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))
656
+ */
657
+ mediaScannable?: boolean;
658
+ /**
659
+ * A boolean value decide whether show a notification when download complete.
660
+ */
661
+ notification?: boolean;
662
+ }
663
+
664
+ export interface RNFetchBlobResponseInfo {
665
+ taskId: string;
666
+ state: string;
667
+ headers: any;
668
+ redirects: string[];
669
+ status: number;
670
+ respType: "text" | "blob" | "" | "json";
671
+ rnfbEncode: "path" | "base64" | "ascii" | "utf8";
672
+ timeout: boolean;
673
+ }
674
+
675
+ export interface RNFetchBlobStream {
676
+ onData(): void;
677
+ onError(): void;
678
+ onEnd(): void;
679
+ }
680
+
681
+ export declare class RNFetchBlobFile {
682
+ }
683
+
684
+ export declare class RNFetchBlobStat {
685
+ lastModified: number;
686
+ size: number;
687
+ type: "directory" | "file";
688
+ path: string;
689
+ filename: string;
690
+ }