|
@@ -98,7 +98,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
98
|
98
|
public boolean reportUploadProgress = false;
|
99
|
99
|
|
100
|
100
|
public RNFetchBlobReq(ReadableMap options, String taskId, String method, String url, ReadableMap headers, String body, ReadableArray arrayBody, final Callback callback) {
|
101
|
|
- this.method = method;
|
|
101
|
+ this.method = method.toUpperCase();
|
102
|
102
|
this.options = new RNFetchBlobConfig(options);
|
103
|
103
|
this.taskId = taskId;
|
104
|
104
|
this.url = url;
|
|
@@ -404,14 +404,13 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
|
404
|
404
|
String dest = RNFetchBlobFS.getTmpPath(ctx, taskId);
|
405
|
405
|
InputStream ins = resp.body().byteStream();
|
406
|
406
|
FileOutputStream os = new FileOutputStream(new File(dest));
|
|
407
|
+ int read;
|
407
|
408
|
byte [] buffer = new byte[10240];
|
408
|
|
- int read = ins.read(buffer);
|
409
|
|
- os.write(buffer,0,read);
|
410
|
|
- while(read > 0) {
|
411
|
|
- os.write(buffer,0,read);
|
412
|
|
- read = ins.read(buffer);
|
|
409
|
+ while ((read = ins.read(buffer)) != -1) {
|
|
410
|
+ os.write(buffer, 0, read);
|
413
|
411
|
}
|
414
|
412
|
ins.close();
|
|
413
|
+ os.flush();
|
415
|
414
|
os.close();
|
416
|
415
|
callback.invoke(null, null, dest);
|
417
|
416
|
}
|