@@ -10,13 +10,19 @@ export default ReactNativeBlobUtil;
10
10
interface ReactNativeBlobUtilStatic {
11
11
fetch ( method : Methods , url : string , headers ?: { [ key : string ] : string } , body ?: any
12
12
| null ) : StatefulPromise < FetchBlobResponse > ;
13
+
13
14
base64 : { encode ( input : string ) : string ; decode ( input : string ) : string } ;
14
15
android : AndroidApi ;
15
16
ios : IOSApi ;
17
+
16
18
config ( options : ReactNativeBlobUtilConfig ) : ReactNativeBlobUtilStatic ;
19
+
17
20
session ( name : string ) : ReactNativeBlobUtilSession ;
21
+
18
22
fs : FS ;
23
+
19
24
wrap ( path : string ) : string ;
25
+
20
26
net : Net ;
21
27
polyfill : Polyfill ;
22
28
// this require external module https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/oboe
@@ -45,10 +51,15 @@ export declare class ReactNativeBlobUtilFetchPolyfill {
45
51
46
52
export interface ReactNativeBlobUtilFetchRepsonse {
47
53
arrayBuffer ( ) : Promise < any [ ] > ;
54
+
48
55
blob ( ) : Promise < PolyfillBlob > ;
56
+
49
57
json ( ) : Promise < any > ;
58
+
50
59
rawResp ( ) : Promise < FetchBlobResponse > ;
60
+
51
61
text ( ) : Promise < string > ;
62
+
52
63
bodyUsed : boolean ;
53
64
headers : any ;
54
65
ok : boolean ;
@@ -64,46 +75,58 @@ export interface ReactNativeBlobUtilFetchRepsonse {
64
75
*/
65
76
export interface FetchBlobResponse {
66
77
taskId : string ;
78
+
67
79
/**
68
80
* get path of response temp file
69
81
* @return File path of temp file.
70
82
*/
71
83
path ( ) : string ;
84
+
72
85
type : "base64" | "path" | "utf8" ;
73
86
data : any ;
87
+
74
88
/**
75
89
* Convert result to javascript ReactNativeBlobUtil object.
76
90
* @return Return a promise resolves Blob object.
77
91
*/
78
92
blob ( contentType : string , sliceSize : number ) : Promise < PolyfillBlob > ;
93
+
79
94
/**
80
95
* Convert result to text.
81
96
* @return Decoded base64 string.
82
97
*/
83
98
text ( ) : string | Promise < any > ;
99
+
84
100
/**
85
101
* Convert result to JSON object.
86
102
* @return Parsed javascript object.
87
103
*/
88
104
json ( ) : any ;
105
+
89
106
/**
90
107
* Return BASE64 string directly.
91
108
* @return BASE64 string of response body.
92
109
*/
93
110
base64 ( ) : any ;
111
+
94
112
/**
95
113
* Remove cahced file
96
114
*/
97
115
flush ( ) : void ;
116
+
98
117
respInfo : ReactNativeBlobUtilResponseInfo ;
118
+
99
119
info ( ) : ReactNativeBlobUtilResponseInfo ;
120
+
100
121
session ( name : string ) : ReactNativeBlobUtilSession | null ;
122
+
101
123
/**
102
124
* Read file content with given encoding, if the response does not contains
103
125
* a file path, show warning message
104
126
* @param encode Encode type, should be one of `base64`, `ascrii`, `utf8`.
105
127
*/
106
128
readFile ( encode : Encoding ) : Promise < any > | null ;
129
+
107
130
/**
108
131
* Start read stream from cached file
109
132
* @param encode Encode type, should be one of `base64`, `ascrii`, `utf8`.
@@ -113,17 +136,27 @@ export interface FetchBlobResponse {
113
136
114
137
export interface PolyfillFileReader extends EventTarget {
115
138
isRNFBPolyFill : boolean ;
139
+
116
140
onloadstart ( e : Event ) : void ;
141
+
117
142
onprogress ( e : Event ) : void ;
143
+
118
144
onload ( e : Event ) : void ;
145
+
119
146
onabort ( e : Event ) : void ;
147
+
120
148
onerror ( e : Event ) : void ;
149
+
121
150
onloadend ( e : Event ) : void ;
122
151
123
152
abort ( ) : void ;
153
+
124
154
readAsArrayBuffer ( b : PolyfillBlob ) : void ;
155
+
125
156
readAsBinaryString ( b : PolyfillBlob ) : void ;
157
+
126
158
readAsText ( b : PolyfillBlob , label ?: string ) : void ;
159
+
127
160
readAsDataURL ( b : PolyfillBlob ) : void ;
128
161
129
162
readyState : number ;
@@ -242,6 +275,7 @@ export interface PolyfillXMLHttpRequest extends PolyfillXMLHttpRequestEventTarge
242
275
getAllResponseHeaders ( ) : string | null ;
243
276
244
277
onreadystatechange ( e : Event ) : void ;
278
+
245
279
readyState : number ;
246
280
status : number ;
247
281
statusText : string ;
@@ -270,11 +304,17 @@ export declare namespace PolyfillXMLHttpRequest {
270
304
271
305
export interface PolyfillXMLHttpRequestEventTarget extends EventTarget {
272
306
onabort ( e : Event ) : void ;
307
+
273
308
onerror ( e : Event ) : void ;
309
+
274
310
onload ( e : Event ) : void ;
311
+
275
312
onloadstart ( e : Event ) : void ;
313
+
276
314
onprogress ( e : Event ) : void ;
315
+
277
316
ontimeout ( e : Event ) : void ;
317
+
278
318
onloadend ( e : Event ) : void ;
279
319
}
280
320
@@ -295,6 +335,7 @@ export interface Net {
295
335
}
296
336
297
337
type HashAlgorithm = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512" ;
338
+
298
339
export interface FS {
299
340
ReactNativeBlobUtilSession : ReactNativeBlobUtilSession ;
300
341
@@ -364,6 +405,7 @@ export interface FS {
364
405
* @param encoding Encoding of read stream.
365
406
*/
366
407
readFile ( path : string , encoding : Encoding , bufferSize ?: number ) : Promise < any > ;
408
+
367
409
/**
368
410
* Check if file exists and if it is a folder.
369
411
* @param path Path to check
@@ -391,7 +433,9 @@ export interface FS {
391
433
dirs : Dirs ;
392
434
393
435
slice ( src : string , dest : string , start : number , end : number ) : Promise < void > ;
436
+
394
437
asset ( path : string ) : string ;
438
+
395
439
df ( ) : Promise < { free : number , total : number } > ;
396
440
}
397
441
@@ -414,6 +458,7 @@ export interface ReactNativeBlobUtilWriteStream {
414
458
append : boolean ;
415
459
416
460
write ( data : string ) : Promise < void > ;
461
+
417
462
close ( ) : void ;
418
463
}
419
464
@@ -512,7 +557,7 @@ export interface AndroidApi {
512
557
actionViewIntent ( path : string , mime : string , chooserTitle ?: string ) : Promise < any > ;
513
558
514
559
/**
515
- *
560
+ *
516
561
* This method brings up OS default file picker and resolves a file URI when the user selected a file.
517
562
* However, it does not resolve or reject when user dismiss the file picker via pressing hardware back button,
518
563
* but you can still handle this behavior via AppState.
@@ -703,7 +748,9 @@ export interface ReactNativeBlobUtilResponseInfo {
703
748
704
749
export interface ReactNativeBlobUtilStream {
705
750
onData ( ) : void ;
751
+
706
752
onError ( ) : void ;
753
+
707
754
onEnd ( ) : void ;
708
755
}
709
756
@@ -717,3 +764,13 @@ export declare class ReactNativeBlobUtilStat {
717
764
path : string ;
718
765
filename : string ;
719
766
}
767
+
768
+ export type Mediatype = "Audio" | "Image" | "Video" | "Download" ;
769
+ export interface MediaCollection {
770
+ /**
771
+ * Creates a new File in the collection.
772
+ * @param filedata
773
+ * @param mediatype
774
+ */
775
+ createMediafile ( filedata : { path : string , parentFolder : string , mimeType : string } , mediatype : Mediatype ) : Promise < string > ;
776
+ }
0 commit comments