|
@@ -9,6 +9,7 @@ import com.facebook.react.bridge.WritableMap;
|
9
|
9
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
10
|
10
|
|
11
|
11
|
import java.io.IOException;
|
|
12
|
+import java.nio.charset.Charset;
|
12
|
13
|
|
13
|
14
|
import okhttp3.Call;
|
14
|
15
|
import okhttp3.Callback;
|
|
@@ -30,11 +31,13 @@ public class RNFetchBlobDefaultResp extends ResponseBody {
|
30
|
31
|
String mTaskId;
|
31
|
32
|
ReactApplicationContext rctContext;
|
32
|
33
|
ResponseBody originalBody;
|
|
34
|
+ boolean isIncrement = false;
|
33
|
35
|
|
34
|
|
- public RNFetchBlobDefaultResp(ReactApplicationContext ctx, String taskId, ResponseBody body) {
|
|
36
|
+ public RNFetchBlobDefaultResp(ReactApplicationContext ctx, String taskId, ResponseBody body, boolean isIncrement) {
|
35
|
37
|
this.rctContext = ctx;
|
36
|
38
|
this.mTaskId = taskId;
|
37
|
39
|
this.originalBody = body;
|
|
40
|
+ this.isIncrement = isIncrement;
|
38
|
41
|
}
|
39
|
42
|
|
40
|
43
|
@Override
|
|
@@ -71,6 +74,13 @@ public class RNFetchBlobDefaultResp extends ResponseBody {
|
71
|
74
|
args.putString("taskId", mTaskId);
|
72
|
75
|
args.putString("written", String.valueOf(bytesRead));
|
73
|
76
|
args.putString("total", String.valueOf(contentLength()));
|
|
77
|
+ if(isIncrement) {
|
|
78
|
+ args.putString("chunk", sink.readString(Charset.defaultCharset()));
|
|
79
|
+ }
|
|
80
|
+ else {
|
|
81
|
+ args.putString("chunk", "");
|
|
82
|
+ }
|
|
83
|
+
|
74
|
84
|
rctContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
75
|
85
|
.emit(RNFetchBlobConst.EVENT_PROGRESS, args);
|
76
|
86
|
}
|