react-native-blob-util 0.19.1 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/.eslintrc.js +56 -56
  2. package/LICENSE +21 -21
  3. package/Migration.md +41 -41
  4. package/README.md +1071 -1071
  5. package/android/gradle.properties +1 -1
  6. package/android/proguard-rules.pro +17 -17
  7. package/android/src/main/AndroidManifest.xml +39 -40
  8. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilConfig.java +57 -57
  9. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilConst.java +20 -20
  10. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java +2 -2
  11. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFileTransformer.java +9 -9
  12. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilImpl.java +431 -431
  13. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilProgressConfig.java +39 -39
  14. package/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java +972 -968
  15. package/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilDefaultResp.java +98 -98
  16. package/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilFileResp.java +157 -157
  17. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/FileDescription.java +19 -19
  18. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/FileProvider.java +4 -4
  19. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/MimeType.java +70 -70
  20. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/PathResolver.java +223 -223
  21. package/android/src/main/java/com/ReactNativeBlobUtil/Utils/Tls12SocketFactory.java +68 -68
  22. package/android/src/main/res/values/strings.xml +3 -3
  23. package/android/src/main/res/xml/provider_paths.xml +12 -12
  24. package/android/src/newarch/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java +1 -1
  25. package/android.js +58 -58
  26. package/class/ReactNativeBlobUtilCanceledFetchError.js +9 -9
  27. package/class/ReactNativeBlobUtilFile.js +5 -5
  28. package/class/ReactNativeBlobUtilReadStream.js +84 -84
  29. package/class/ReactNativeBlobUtilSession.js +68 -68
  30. package/class/ReactNativeBlobUtilWriteStream.js +50 -50
  31. package/class/StatefulPromise.js +7 -7
  32. package/codegenSpecs/NativeBlobUtils.js +86 -82
  33. package/components/Fetch.onPress.js +10 -10
  34. package/components/Fetch.when.js +15 -15
  35. package/fetch.js +344 -344
  36. package/fs.js +480 -480
  37. package/index.d.ts +871 -871
  38. package/index.js +64 -64
  39. package/index.js.flow +191 -191
  40. package/index.web.js +1 -1
  41. package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.h +55 -55
  42. package/ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm +993 -993
  43. package/ios/ReactNativeBlobUtil.xcodeproj/project.pbxproj +403 -403
  44. package/ios/ReactNativeBlobUtilConst.h +58 -58
  45. package/ios/ReactNativeBlobUtilConst.mm +47 -47
  46. package/ios/ReactNativeBlobUtilFS.h +108 -108
  47. package/ios/ReactNativeBlobUtilFS.mm +977 -977
  48. package/ios/ReactNativeBlobUtilFileTransformer.h +23 -23
  49. package/ios/ReactNativeBlobUtilFileTransformer.mm +20 -20
  50. package/ios/ReactNativeBlobUtilNetwork.h +49 -49
  51. package/ios/ReactNativeBlobUtilNetwork.mm +159 -159
  52. package/ios/ReactNativeBlobUtilProgress.h +32 -32
  53. package/ios/ReactNativeBlobUtilProgress.mm +57 -57
  54. package/ios/ReactNativeBlobUtilReqBuilder.h +37 -37
  55. package/ios/ReactNativeBlobUtilReqBuilder.mm +292 -292
  56. package/ios/ReactNativeBlobUtilRequest.h +48 -48
  57. package/ios/ReactNativeBlobUtilRequest.mm +535 -535
  58. package/ios.js +61 -61
  59. package/json-stream.js +42 -42
  60. package/lib/oboe-browser.js +2703 -2703
  61. package/mediacollection.js +36 -36
  62. package/package.json +55 -55
  63. package/polyfill/Blob.js +362 -362
  64. package/polyfill/Event.js +11 -11
  65. package/polyfill/EventTarget.js +78 -78
  66. package/polyfill/Fetch.js +219 -219
  67. package/polyfill/File.js +27 -27
  68. package/polyfill/FileReader.js +91 -91
  69. package/polyfill/ProgressEvent.js +32 -32
  70. package/polyfill/XMLHttpRequest.js +466 -466
  71. package/polyfill/XMLHttpRequestEventTarget.js +126 -126
  72. package/polyfill/index.js +11 -11
  73. package/react-native-blob-util.podspec +45 -45
  74. package/types.js +69 -69
  75. package/utils/log.js +40 -40
  76. package/utils/unicode.js +7 -7
  77. package/utils/uri.js +33 -33
  78. package/utils/uuid.js +4 -4
  79. package/windows/README.md +2 -2
  80. package/windows/ReactNativeBlobUtil/PropertySheet.props +15 -15
  81. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.cpp +1701 -1693
  82. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.def +3 -3
  83. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.h +379 -366
  84. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.vcxproj +181 -181
  85. package/windows/ReactNativeBlobUtil/ReactNativeBlobUtil.vcxproj.filters +31 -31
  86. package/windows/ReactNativeBlobUtil/ReactPackageProvider.cpp +15 -15
  87. package/windows/ReactNativeBlobUtil/ReactPackageProvider.h +20 -20
  88. package/windows/ReactNativeBlobUtil/ReactPackageProvider.idl +9 -9
  89. package/windows/ReactNativeBlobUtil/packages.config +3 -3
  90. package/windows/ReactNativeBlobUtil/pch.cpp +1 -1
  91. package/windows/ReactNativeBlobUtil/pch.h +3 -3
package/index.js CHANGED
@@ -1,64 +1,64 @@
1
- // Copyright 2016 wkh237@github. All rights reserved.
2
- // Use of this source code is governed by a MIT-style license that can be
3
- // found in the LICENSE file.
4
-
5
- import ReactNativeBlobUtil from './codegenSpecs/NativeBlobUtils';
6
-
7
- //import StatefulPromise from './class/StatefulPromise.js'
8
- import fs from './fs';
9
- import MediaCollection from './mediacollection';
10
- import base64 from 'base-64';
11
- import polyfill from './polyfill';
12
- import android from './android';
13
- import ios from './ios';
14
- import JSONStream from './json-stream';
15
- import {config, fetch} from './fetch';
16
- import URIUtil from './utils/uri';
17
- import CanceledFetchError from './class/ReactNativeBlobUtilCanceledFetchError';
18
-
19
- const {
20
- ReactNativeBlobUtilSession,
21
- readStream,
22
- createFile,
23
- unlink,
24
- exists,
25
- mkdir,
26
- session,
27
- writeStream,
28
- readFile,
29
- ls,
30
- isDir,
31
- mv,
32
- cp
33
- } = fs;
34
-
35
- const Blob = polyfill.Blob;
36
- const wrap = URIUtil.wrap;
37
-
38
- // Show warning if native module not detected
39
- if (!ReactNativeBlobUtil || !ReactNativeBlobUtil.fetchBlobForm || !ReactNativeBlobUtil.fetchBlob) {
40
- console.warn(
41
- 'react-native-blob-util could not find valid native module.',
42
- 'please make sure you have linked native modules using `rnpm link`,',
43
- 'and restart RN packager or manually compile IOS/Android project.'
44
- );
45
- }
46
-
47
- export {ReactNativeBlobUtilConfig, ReactNativeBlobUtilResponseInfo, ReactNativeBlobUtilStream} from './types';
48
- export { URIUtil } from './utils/uri';
49
- export {FetchBlobResponse} from './class/ReactNativeBlobUtilBlobResponse';
50
- export { getUUID } from './utils/uuid';
51
- export default {
52
- fetch,
53
- base64,
54
- android,
55
- ios,
56
- config,
57
- session,
58
- fs,
59
- wrap,
60
- polyfill,
61
- JSONStream,
62
- MediaCollection,
63
- CanceledFetchError
64
- };
1
+ // Copyright 2016 wkh237@github. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import ReactNativeBlobUtil from './codegenSpecs/NativeBlobUtils';
6
+
7
+ //import StatefulPromise from './class/StatefulPromise.js'
8
+ import fs from './fs';
9
+ import MediaCollection from './mediacollection';
10
+ import base64 from 'base-64';
11
+ import polyfill from './polyfill';
12
+ import android from './android';
13
+ import ios from './ios';
14
+ import JSONStream from './json-stream';
15
+ import {config, fetch} from './fetch';
16
+ import URIUtil from './utils/uri';
17
+ import CanceledFetchError from './class/ReactNativeBlobUtilCanceledFetchError';
18
+
19
+ const {
20
+ ReactNativeBlobUtilSession,
21
+ readStream,
22
+ createFile,
23
+ unlink,
24
+ exists,
25
+ mkdir,
26
+ session,
27
+ writeStream,
28
+ readFile,
29
+ ls,
30
+ isDir,
31
+ mv,
32
+ cp
33
+ } = fs;
34
+
35
+ const Blob = polyfill.Blob;
36
+ const wrap = URIUtil.wrap;
37
+
38
+ // Show warning if native module not detected
39
+ if (!ReactNativeBlobUtil || !ReactNativeBlobUtil.fetchBlobForm || !ReactNativeBlobUtil.fetchBlob) {
40
+ console.warn(
41
+ 'react-native-blob-util could not find valid native module.',
42
+ 'please make sure you have linked native modules using `rnpm link`,',
43
+ 'and restart RN packager or manually compile IOS/Android project.'
44
+ );
45
+ }
46
+
47
+ export {ReactNativeBlobUtilConfig, ReactNativeBlobUtilResponseInfo, ReactNativeBlobUtilStream} from './types';
48
+ export { URIUtil } from './utils/uri';
49
+ export {FetchBlobResponse} from './class/ReactNativeBlobUtilBlobResponse';
50
+ export { getUUID } from './utils/uuid';
51
+ export default {
52
+ fetch,
53
+ base64,
54
+ android,
55
+ ios,
56
+ config,
57
+ session,
58
+ fs,
59
+ wrap,
60
+ polyfill,
61
+ JSONStream,
62
+ MediaCollection,
63
+ CanceledFetchError
64
+ };
package/index.js.flow CHANGED
@@ -1,191 +1,191 @@
1
- // @flow strict
2
-
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>;
9
- }
10
-
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>;
28
- }
29
-
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>;
55
- }
56
-
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>;
61
- }
62
-
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;
73
- }
74
-
75
- declare class ReactNativeBlobUtilSession {
76
- static getSession(name: string): ReactNativeBlobUtilSession;
77
- static removeSession(name: string): void;
78
- static setSession(name: string, val: ReactNativeBlobUtilSession): void;
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;
86
- }
87
-
88
- declare class ReactNativeBlobUtilWriteStream {
89
- append: boolean;
90
- encoding: string;
91
- id: string;
92
- close(): void;
93
- write(data: string): Promise<void>;
94
- }
95
-
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;
105
- }
106
-
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>;
113
- }
114
-
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
123
- };
124
- export type AndroidDownloadOption = {
125
- description?: string,
126
- mime?: string,
127
- path: string,
128
- showNotification?: boolean,
129
- title?: string
130
- };
131
- export type AndroidFsStat = {
132
- external_free: number,
133
- external_total: number,
134
- internal_free: number,
135
- internal_total: number
136
- };
137
- 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
149
- };
150
- export type Encoding = "utf8" | "ascii" | "base64";
151
- export type FormField = {data: string, filename?: string, name: string, type?: string};
152
- export type HashAlgorithm = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512";
153
- export type IosFsStat = {free: number, total: number};
154
- export type Methods = "POST" | "GET" | "DELETE" | "PUT" | "post" | "get" | "delete" | "put";
155
- export type ProgressCallback = (received: number, total: number) => void;
156
- 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
171
- };
172
- 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
181
- };
182
- export type ReactNativeBlobUtilStat = {
183
- filename: string,
184
- lastModified: number,
185
- path: string,
186
- size: number,
187
- type: "directory" | "file" | "asset"
188
- };
189
- export type UploadProgressCallback = (sent: number, total: number) => void;
190
-
191
- declare export default ReactNativeBlobUtil;
1
+ // @flow strict
2
+
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>;
9
+ }
10
+
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>;
28
+ }
29
+
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>;
55
+ }
56
+
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>;
61
+ }
62
+
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;
73
+ }
74
+
75
+ declare class ReactNativeBlobUtilSession {
76
+ static getSession(name: string): ReactNativeBlobUtilSession;
77
+ static removeSession(name: string): void;
78
+ static setSession(name: string, val: ReactNativeBlobUtilSession): void;
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;
86
+ }
87
+
88
+ declare class ReactNativeBlobUtilWriteStream {
89
+ append: boolean;
90
+ encoding: string;
91
+ id: string;
92
+ close(): void;
93
+ write(data: string): Promise<void>;
94
+ }
95
+
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;
105
+ }
106
+
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>;
113
+ }
114
+
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
123
+ };
124
+ export type AndroidDownloadOption = {
125
+ description?: string,
126
+ mime?: string,
127
+ path: string,
128
+ showNotification?: boolean,
129
+ title?: string
130
+ };
131
+ export type AndroidFsStat = {
132
+ external_free: number,
133
+ external_total: number,
134
+ internal_free: number,
135
+ internal_total: number
136
+ };
137
+ 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
149
+ };
150
+ export type Encoding = "utf8" | "ascii" | "base64";
151
+ export type FormField = {data: string, filename?: string, name: string, type?: string};
152
+ export type HashAlgorithm = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512";
153
+ export type IosFsStat = {free: number, total: number};
154
+ export type Methods = "POST" | "GET" | "DELETE" | "PUT" | "post" | "get" | "delete" | "put";
155
+ export type ProgressCallback = (received: number, total: number) => void;
156
+ 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
171
+ };
172
+ 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
181
+ };
182
+ export type ReactNativeBlobUtilStat = {
183
+ filename: string,
184
+ lastModified: number,
185
+ path: string,
186
+ size: number,
187
+ type: "directory" | "file" | "asset"
188
+ };
189
+ export type UploadProgressCallback = (sent: number, total: number) => void;
190
+
191
+ declare export default ReactNativeBlobUtil;
package/index.web.js CHANGED
@@ -1 +1 @@
1
- export default {};
1
+ export default {};
@@ -1,55 +1,55 @@
1
- //
2
- // ReactNativeBlobUtil.h
3
- //
4
- // Created by wkh237 on 2016/4/28.
5
- //
6
-
7
- //XXX: DO NO REMOVE THIS LINE IF YOU'RE USING IT ON RN > 0.40 PROJECT
8
-
9
-
10
-
11
- #ifndef ReactNativeBlobUtil_h
12
- #define ReactNativeBlobUtil_h
13
-
14
-
15
- #if __has_include(<React/RCTAssert.h>)
16
- #import <React/RCTLog.h>
17
- #import <React/RCTRootView.h>
18
- #import <React/RCTBridge.h>
19
- #import <React/RCTBridgeModule.h>
20
- #import <React/RCTEventEmitter.h>
21
- #else
22
- #import "RCTBridgeModule.h"
23
- #import "RCTLog.h"
24
- #import "RCTRootView.h"
25
- #import "RCTBridge.h"
26
- #import "RCTEventEmitter.h"
27
- #endif
28
-
29
- #import <UIKit/UIKit.h>
30
-
31
- #if RCT_NEW_ARCH_ENABLED
32
- #import <ReactNativeBlobUtilSpec/ReactNativeBlobUtilSpec.h>
33
- #endif
34
-
35
-
36
- @interface ReactNativeBlobUtil : RCTEventEmitter <RCTBridgeModule, UIDocumentInteractionControllerDelegate> {
37
-
38
- NSString * filePathPrefix;
39
-
40
- }
41
-
42
- @property (nonatomic) NSString * filePathPrefix;
43
- @property (retain) UIDocumentInteractionController * documentController;
44
-
45
- -(void) emitEvent:(NSString *)name body:(NSString *) body;
46
- -(void) emitEventDict:(NSString *)name body:(NSDictionary *) body;
47
-
48
- @end
49
-
50
- #if RCT_NEW_ARCH_ENABLED
51
- @interface ReactNativeBlobUtil () <NativeBlobUtilsSpec>
52
- @end
53
- #endif
54
-
55
- #endif /* ReactNativeBlobUtil_h */
1
+ //
2
+ // ReactNativeBlobUtil.h
3
+ //
4
+ // Created by wkh237 on 2016/4/28.
5
+ //
6
+
7
+ //XXX: DO NO REMOVE THIS LINE IF YOU'RE USING IT ON RN > 0.40 PROJECT
8
+
9
+
10
+
11
+ #ifndef ReactNativeBlobUtil_h
12
+ #define ReactNativeBlobUtil_h
13
+
14
+
15
+ #if __has_include(<React/RCTAssert.h>)
16
+ #import <React/RCTLog.h>
17
+ #import <React/RCTRootView.h>
18
+ #import <React/RCTBridge.h>
19
+ #import <React/RCTBridgeModule.h>
20
+ #import <React/RCTEventEmitter.h>
21
+ #else
22
+ #import "RCTBridgeModule.h"
23
+ #import "RCTLog.h"
24
+ #import "RCTRootView.h"
25
+ #import "RCTBridge.h"
26
+ #import "RCTEventEmitter.h"
27
+ #endif
28
+
29
+ #import <UIKit/UIKit.h>
30
+
31
+ #if RCT_NEW_ARCH_ENABLED
32
+ #import <ReactNativeBlobUtilSpec/ReactNativeBlobUtilSpec.h>
33
+ #endif
34
+
35
+
36
+ @interface ReactNativeBlobUtil : RCTEventEmitter <RCTBridgeModule, UIDocumentInteractionControllerDelegate> {
37
+
38
+ NSString * filePathPrefix;
39
+
40
+ }
41
+
42
+ @property (nonatomic) NSString * filePathPrefix;
43
+ @property (retain) UIDocumentInteractionController * documentController;
44
+
45
+ -(void) emitEvent:(NSString *)name body:(NSString *) body;
46
+ -(void) emitEventDict:(NSString *)name body:(NSDictionary *) body;
47
+
48
+ @end
49
+
50
+ #if RCT_NEW_ARCH_ENABLED
51
+ @interface ReactNativeBlobUtil () <NativeBlobUtilsSpec>
52
+ @end
53
+ #endif
54
+
55
+ #endif /* ReactNativeBlobUtil_h */