File tree 2 files changed +17
-3
lines changed
android/src/main/java/com/RNFetchBlob
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -531,16 +531,26 @@ private void done(Response resp) {
531
531
}
532
532
break ;
533
533
case FileStorage :
534
+ ResponseBody responseBody = resp .body ();
535
+
534
536
try {
535
537
// In order to write response data to `destPath` we have to invoke this method.
536
538
// It uses customized response body which is able to report download progress
537
539
// and write response data to destination path.
538
- resp . body () .bytes ();
540
+ responseBody .bytes ();
539
541
} catch (Exception ignored ) {
540
542
// ignored.printStackTrace();
541
543
}
542
- this .destPath = this .destPath .replace ("?append=true" , "" );
543
- callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_PATH , this .destPath );
544
+
545
+ RNFetchBlobFileResp rnFetchBlobFileResp = (RNFetchBlobFileResp ) responseBody ;
546
+
547
+ if (rnFetchBlobFileResp != null && rnFetchBlobFileResp .isDownloadComplete () == false ){
548
+ callback .invoke ("RNFetchBlob failed. Download interrupted." , null );
549
+ }
550
+ else {
551
+ this .destPath = this .destPath .replace ("?append=true" , "" );
552
+ callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_PATH , this .destPath );
553
+ }
544
554
break ;
545
555
default :
546
556
try {
Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ public long contentLength() {
69
69
return originalBody .contentLength ();
70
70
}
71
71
72
+ public boolean isDownloadComplete () {
73
+ return bytesDownloaded == contentLength ();
74
+ }
75
+
72
76
@ Override
73
77
public BufferedSource source () {
74
78
ProgressReportingSource countable = new ProgressReportingSource ();
You can’t perform that action at this time.
0 commit comments