Browse Source

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

Ben Hsieh 8 years ago
parent
commit
c72e6d7ec6
1 changed files with 2 additions and 4 deletions
  1. 2
    4
      src/android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java

+ 2
- 4
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java View File

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