@@ -116,6 +116,7 @@ private boolean shouldTransformFile() {
116116 String url ;
117117 String rawRequestBody ;
118118 String destPath ;
119+ String customPath ;
119120 ReadableArray rawRequestBodyArray ;
120121 ReadableMap headers ;
121122 Callback callback ;
@@ -237,7 +238,10 @@ public boolean handleMessage(Message msg) {
237238 @ Override
238239 public void run () {
239240 Context appCtx = ReactNativeBlobUtilImpl .RCTContext .getApplicationContext ();
240-
241+ String t123 = String .valueOf (options .addAndroidDownloads .hasKey ("storeLocal" ));
242+ String t1234 = String .valueOf (options .addAndroidDownloads .getBoolean ("storeLocal" ));
243+ RNLog .w (ReactNativeBlobUtilImpl .RCTContext , t123 );
244+ RNLog .w (ReactNativeBlobUtilImpl .RCTContext , t1234 );
241245 // use download manager instead of default HTTP implementation
242246 if (options .addAndroidDownloads != null && options .addAndroidDownloads .hasKey ("useDownloadManager" )) {
243247
@@ -269,16 +273,18 @@ public void run() {
269273 }
270274 }
271275 req .setDestinationUri (Uri .parse ("file://" + path ));
276+
277+ customPath = path ;
272278 }
273279
274280
275281 if (options .addAndroidDownloads .hasKey ("storeLocal" ) && options .addAndroidDownloads .getBoolean ("storeLocal" )) {
276- String path = (String ) ReactNativeBlobUtilFS .getSystemfolders ((ReactApplicationContext ) appCtx ).get ("DownloadDir" );
282+ RNLog .w (ReactNativeBlobUtilImpl .RCTContext , "a" );
283+ String path = (String ) ReactNativeBlobUtilFS .getSystemfolders (ReactNativeBlobUtilImpl .RCTContext ).get ("DownloadDir" );
277284 path = path + UUID .randomUUID ().toString ();
278285
279286 File f = new File (path );
280287 File dir = f .getParentFile ();
281-
282288 if (!f .exists ()) {
283289 if (dir != null && !dir .exists ()) {
284290 if (!dir .mkdirs () && !dir .exists ()) {
@@ -288,6 +294,7 @@ public void run() {
288294 }
289295 }
290296 req .setDestinationUri (Uri .parse ("file://" + path ));
297+ customPath = path ;
291298 }
292299
293300 if (options .addAndroidDownloads .hasKey ("mime" )) {
@@ -333,7 +340,7 @@ public void run() {
333340 appCtx .registerReceiver (this , new IntentFilter (DownloadManager .ACTION_DOWNLOAD_COMPLETE ), Context .RECEIVER_EXPORTED );
334341 }else {
335342 appCtx .registerReceiver (this , new IntentFilter (DownloadManager .ACTION_DOWNLOAD_COMPLETE ));
336- }
343+ }
337344 future = scheduledExecutorService .scheduleAtFixedRate (new Runnable () {
338345 @ Override
339346 public void run () {
@@ -952,9 +959,9 @@ public void onReceive(Context context, Intent intent) {
952959 }
953960
954961 // When the file is not found in media content database, check if custom path exists
955- if (options .addAndroidDownloads .hasKey ("path" )) {
962+ if (options .addAndroidDownloads .hasKey ("path" ) || options . addAndroidDownloads . hasKey ( "storeLocal" ) ) {
956963 try {
957- String customDest = options . addAndroidDownloads . getString ( "path" ) ;
964+ String customDest = customPath ;
958965 boolean exists = new File (customDest ).exists ();
959966 if (!exists )
960967 throw new Exception ("Download manager download failed, the file does not downloaded to destination." );
0 commit comments