@@ -156,7 +156,7 @@ public void run() {
156156
157157 // find cached result if `key` property exists
158158 String cacheKey = this .taskId ;
159- String ext = this .options .appendExt != "" ? "." + this .options .appendExt : "" ;
159+ String ext = this .options .appendExt . isEmpty () ? "." + this .options .appendExt : "" ;
160160
161161 if (this .options .key != null ) {
162162 cacheKey = RNFetchBlobUtils .getMD5 (this .options .key );
@@ -174,7 +174,7 @@ public void run() {
174174
175175 if (this .options .path != null )
176176 this .destPath = this .options .path ;
177- else if (this .options .fileCache == true )
177+ else if (this .options .fileCache )
178178 this .destPath = RNFetchBlobFS .getTmpPath (RNFetchBlob .RCTContext , cacheKey ) + ext ;
179179
180180 OkHttpClient .Builder clientBuilder ;
@@ -212,7 +212,7 @@ else if(this.options.fileCache == true)
212212 if (rawRequestBodyArray != null ) {
213213 requestType = RequestType .Form ;
214214 }
215- else if (cType == null || cType .isEmpty ()) {
215+ else if (cType .isEmpty ()) {
216216 builder .header ("Content-Type" , "application/octet-stream" );
217217 requestType = RequestType .SingleFile ;
218218 }
@@ -280,7 +280,7 @@ else if(cType == null || cType.isEmpty()) {
280280
281281 final Request req = builder .build ();
282282
283- // Create response body depends on the responseType
283+ // Add request interceptor for upload progress event
284284 clientBuilder .addInterceptor (new Interceptor () {
285285 @ Override
286286 public Response intercept (Chain chain ) throws IOException {
@@ -310,15 +310,13 @@ public Response intercept(Chain chain) throws IOException {
310310 }
311311 return originalResponse .newBuilder ().body (extended ).build ();
312312 }
313- catch ( SocketTimeoutException e ){
313+ catch ( SocketException e ) {
314314 timeout = true ;
315315 }
316- catch (SocketException ex ) {
316+ catch (SocketTimeoutException e ) {
317317 timeout = true ;
318- }
319- catch (Exception ex ) {
318+ } catch (Exception ex ) {
320319 RNFetchBlobUtils .emitWarningEvent ("RNFetchBlob error when sending request : " + ex .getLocalizedMessage ());
321-
322320 }
323321 return chain .proceed (chain .request ());
324322 }
@@ -611,7 +609,7 @@ public void onReceive(Context context, Intent intent) {
611609 }
612610 }
613611 else
614- this .callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_PATH , filePath );
612+ this .callback .invoke ("Download manager could not resolve downloaded file path." , RNFetchBlobConst .RNFB_RESPONSE_PATH , null );
615613 }
616614 }
617615 }
0 commit comments