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
 
61
 
62
         @Override
62
         @Override
63
         public long read(Buffer sink, long byteCount) throws IOException {
63
         public long read(Buffer sink, long byteCount) throws IOException {
64
-            bytesRead += byteCount;
64
+
65
             long read =  mOriginalSource.read(sink, byteCount);
65
             long read =  mOriginalSource.read(sink, byteCount);
66
+            bytesRead += read;
66
             WritableMap args = Arguments.createMap();
67
             WritableMap args = Arguments.createMap();
67
             args.putString("taskId", mTaskId);
68
             args.putString("taskId", mTaskId);
68
             args.putString("written", String.valueOf(bytesRead));
69
             args.putString("written", String.valueOf(bytesRead));

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

68
             count++;
68
             count++;
69
             byte [] bytes = new byte[(int) byteCount];
69
             byte [] bytes = new byte[(int) byteCount];
70
             long read = originalBody.byteStream().read(bytes, 0, (int) byteCount);
70
             long read = originalBody.byteStream().read(bytes, 0, (int) byteCount);
71
+            bytesUploaded += read > 0 ? read : 0;
71
             if(read > 0) {
72
             if(read > 0) {
72
                 bytesUploaded += read;
73
                 bytesUploaded += read;
73
                 ofStream.write(bytes, 0, (int) read);
74
                 ofStream.write(bytes, 0, (int) read);

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

27
 
27
 
28
 let prefix = ((Platform.OS === 'android') ? 'file://' : '')
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
   let promises = []
32
   let promises = []
33
   let progress = []
33
   let progress = []