Pārlūkot izejas kodu

Add Android upload progress support when sending the body As-Is #120

Ben Hsieh 8 gadus atpakaļ
vecāks
revīzija
c72e6d7ec6

+ 2
- 4
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java Parādīt failu

@@ -75,6 +75,7 @@ public class RNFetchBlobBody extends RequestBody{
75 75
                     break;
76 76
                 case AsIs:
77 77
                     contentLength = this.rawBody.getBytes().length;
78
+                    requestStream = new ByteArrayInputStream(this.rawBody.getBytes());
78 79
                     break;
79 80
                 case Others:
80 81
                     break;
@@ -117,10 +118,7 @@ public class RNFetchBlobBody extends RequestBody{
117 118
     @Override
118 119
     public void writeTo(BufferedSink sink) {
119 120
         try {
120
-            if (requestType == RNFetchBlobReq.RequestType.AsIs)
121
-                sink.write(rawBody.getBytes());
122
-            else
123
-                pipeStreamToSink(requestStream, sink);
121
+            pipeStreamToSink(requestStream, sink);
124 122
         } catch(Exception ex) {
125 123
             RNFetchBlobUtils.emitWarningEvent(ex.getLocalizedMessage());
126 124
             ex.printStackTrace();