Преглед изворни кода

Update RNFetchBlobReq.java

added class cast exception for FileStorage response type.
ihavenoface5 пре 4 година
родитељ
комит
c6b372766f
No account linked to committer's email address
1 измењених фајлова са 11 додато и 1 уклоњено
  1. 11
    1
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 11
- 1
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java Прегледај датотеку

@@ -591,7 +591,17 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
591 591
 //                    ignored.printStackTrace();
592 592
                 }
593 593
 
594
-                RNFetchBlobFileResp rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
594
+                try {
595
+                    RNFetchBlobFileResp rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
596
+                } catch (ClassCastException ex) {
597
+                    // unexpected response type
598
+                    if (responseBody != null) {
599
+                        callback.invoke("Unexpected FileStorage response file: " + responseBody.string(), null);
600
+                    } else {
601
+                        callback.invoke("Unexpected FileStorage response with no file.", null);
602
+                    }
603
+                    return;
604
+                }
595 605
 
596 606
                 if(rnFetchBlobFileResp != null && !rnFetchBlobFileResp.isDownloadComplete()){
597 607
                     callback.invoke("Download interrupted.", null);