Skip to content

Commit d549db1

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix-android-download-manager-cookies
2 parents 90211cb + 1933faf commit d549db1

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,25 @@ private void done(Response resp) {
602602
// ignored.printStackTrace();
603603
}
604604

605-
RNFetchBlobFileResp rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
605+
RNFetchBlobFileResp rnFetchBlobFileResp;
606+
607+
try {
608+
rnFetchBlobFileResp = (RNFetchBlobFileResp) responseBody;
609+
} catch (ClassCastException ex) {
610+
// unexpected response type
611+
if (responseBody != null) {
612+
String responseBodyString = null;
613+
try {
614+
responseBodyString = responseBody.string();
615+
} catch(IOException exception) {
616+
exception.printStackTrace();
617+
}
618+
callback.invoke("Unexpected FileStorage response file: " + responseBodyString, null);
619+
} else {
620+
callback.invoke("Unexpected FileStorage response with no file.", null);
621+
}
622+
return;
623+
}
606624

607625
if(rnFetchBlobFileResp != null && !rnFetchBlobFileResp.isDownloadComplete()){
608626
callback.invoke("Download interrupted.", null);

0 commit comments

Comments
 (0)