Browse Source

Add android error handling

Ben Hsieh 8 years ago
parent
commit
e97068c796

+ 8
- 3
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java View File

179
                 }
179
                 }
180
             }
180
             }
181
         } else {
181
         } else {
182
-            byte[] bytes = Base64.decode(rawBody, 0);
183
-            contentLength = bytes.length;
184
-            requestStream = new ByteArrayInputStream(bytes);
182
+            try {
183
+                byte[] bytes = Base64.decode(rawBody, 0);
184
+                contentLength = bytes.length;
185
+                requestStream = new ByteArrayInputStream(bytes);
186
+            } catch(Exception ex) {
187
+
188
+                Log.e("error", ex.getLocalizedMessage());
189
+            }
185
         }
190
         }
186
         if(requestStream != null)
191
         if(requestStream != null)
187
             pipeStreamToSink(requestStream, sink);
192
             pipeStreamToSink(requestStream, sink);

+ 1
- 1
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobConfig.java View File

18
     public String key;
18
     public String key;
19
     public String mime;
19
     public String mime;
20
     public Boolean auto;
20
     public Boolean auto;
21
-    public long timeout = -1;
21
+    public long timeout = 60000;
22
     public ReadableArray binaryContentTypes = null;
22
     public ReadableArray binaryContentTypes = null;
23
 
23
 
24
     RNFetchBlobConfig(ReadableMap options) {
24
     RNFetchBlobConfig(ReadableMap options) {

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

451
                 break;
451
                 break;
452
         }
452
         }
453
         removeTaskInfo();
453
         removeTaskInfo();
454
+        resp.close();
454
     }
455
     }
455
 
456
 
456
     /**
457
     /**