Sfoglia il codice sorgente

Merge pull request #530 from joltup/filestorage-class-cast-exception-1

Update RNFetchBlobReq.java
Travis Nuttall 4 anni fa
parent
commit
a10c81d658
No account linked to committer's email address
1 ha cambiato i file con 11 aggiunte e 1 eliminazioni
  1. 11
    1
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 11
- 1
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java Vedi File

@@ -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);