Browse Source

Correct Android upload task #49 #25

Ben Hsieh 8 years ago
parent
commit
4fe6a3e10a

+ 2
- 1
src/android/src/main/java/com/RNFetchBlob/Response/RNFetchBlobDefaultResp.java View File

@@ -61,8 +61,9 @@ public class RNFetchBlobDefaultResp extends ResponseBody {
61 61
 
62 62
         @Override
63 63
         public long read(Buffer sink, long byteCount) throws IOException {
64
-            bytesRead += byteCount;
64
+
65 65
             long read =  mOriginalSource.read(sink, byteCount);
66
+            bytesRead += read;
66 67
             WritableMap args = Arguments.createMap();
67 68
             args.putString("taskId", mTaskId);
68 69
             args.putString("written", String.valueOf(bytesRead));

+ 1
- 0
src/android/src/main/java/com/RNFetchBlob/Response/RNFetchBlobFileResp.java View File

@@ -68,6 +68,7 @@ public class RNFetchBlobFileResp extends ResponseBody {
68 68
             count++;
69 69
             byte [] bytes = new byte[(int) byteCount];
70 70
             long read = originalBody.byteStream().read(bytes, 0, (int) byteCount);
71
+            bytesUploaded += read > 0 ? read : 0;
71 72
             if(read > 0) {
72 73
                 bytesUploaded += read;
73 74
                 ofStream.write(bytes, 0, (int) read);

+ 1
- 1
test/test-0.6.3.js View File

@@ -27,7 +27,7 @@ const  dirs = RNFetchBlob.fs.dirs
27 27
 
28 28
 let prefix = ((Platform.OS === 'android') ? 'file://' : '')
29 29
 
30
-false && describe('massive HTTP request', (report, done) => {
30
+describe('massive HTTP request', (report, done) => {
31 31
 
32 32
   let promises = []
33 33
   let progress = []