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,9 +179,14 @@ public class RNFetchBlobBody extends RequestBody{
179 179
                 }
180 180
             }
181 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 191
         if(requestStream != null)
187 192
             pipeStreamToSink(requestStream, sink);

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

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

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

@@ -451,6 +451,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
451 451
                 break;
452 452
         }
453 453
         removeTaskInfo();
454
+        resp.close();
454 455
     }
455 456
 
456 457
     /**