|
@@ -19,14 +19,16 @@ export default class RNFetchBlobReadStream {
|
19
|
19
|
encoding : 'utf8' | 'ascii' | 'base64';
|
20
|
20
|
bufferSize : ?number;
|
21
|
21
|
closed : boolean;
|
|
22
|
+ tick : number = 10;
|
22
|
23
|
|
23
|
|
- constructor(path:string, encoding:string, bufferSize?:?number) {
|
|
24
|
+ constructor(path:string, encoding:string, bufferSize?:?number, tick:number) {
|
24
|
25
|
if(!path)
|
25
|
26
|
throw Error('RNFetchBlob could not open file stream with empty `path`')
|
26
|
27
|
this.encoding = encoding || 'utf8'
|
27
|
28
|
this.bufferSize = bufferSize
|
28
|
29
|
this.path = path
|
29
|
30
|
this.closed = false
|
|
31
|
+ this.tick = tick
|
30
|
32
|
this._onData = () => {}
|
31
|
33
|
this._onEnd = () => {}
|
32
|
34
|
this._onError = () => {}
|
|
@@ -37,7 +39,7 @@ export default class RNFetchBlobReadStream {
|
37
|
39
|
let {event, detail} = e
|
38
|
40
|
if(this._onData && event === 'data') {
|
39
|
41
|
this._onData(detail)
|
40
|
|
- return
|
|
42
|
+ return
|
41
|
43
|
}
|
42
|
44
|
else if (this._onEnd && event === 'end') {
|
43
|
45
|
this._onEnd(detail)
|
|
@@ -59,7 +61,7 @@ export default class RNFetchBlobReadStream {
|
59
|
61
|
|
60
|
62
|
open() {
|
61
|
63
|
if(!this.closed)
|
62
|
|
- RNFetchBlob.readStream(this.path, this.encoding, this.bufferSize || 0, this.streamId)
|
|
64
|
+ RNFetchBlob.readStream(this.path, this.encoding, this.bufferSize || 10240 , this.tick || -1, this.streamId)
|
63
|
65
|
else
|
64
|
66
|
throw new Error('Stream closed')
|
65
|
67
|
}
|