@@ -116,6 +116,7 @@ private boolean shouldTransformFile() {
116
116
String url ;
117
117
String rawRequestBody ;
118
118
String destPath ;
119
+ String customPath ;
119
120
ReadableArray rawRequestBodyArray ;
120
121
ReadableMap headers ;
121
122
Callback callback ;
@@ -237,7 +238,10 @@ public boolean handleMessage(Message msg) {
237
238
@ Override
238
239
public void run () {
239
240
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 );
241
245
// use download manager instead of default HTTP implementation
242
246
if (options .addAndroidDownloads != null && options .addAndroidDownloads .hasKey ("useDownloadManager" )) {
243
247
@@ -269,16 +273,18 @@ public void run() {
269
273
}
270
274
}
271
275
req .setDestinationUri (Uri .parse ("file://" + path ));
276
+
277
+ customPath = path ;
272
278
}
273
279
274
280
275
281
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" );
277
284
path = path + UUID .randomUUID ().toString ();
278
285
279
286
File f = new File (path );
280
287
File dir = f .getParentFile ();
281
-
282
288
if (!f .exists ()) {
283
289
if (dir != null && !dir .exists ()) {
284
290
if (!dir .mkdirs () && !dir .exists ()) {
@@ -288,6 +294,7 @@ public void run() {
288
294
}
289
295
}
290
296
req .setDestinationUri (Uri .parse ("file://" + path ));
297
+ customPath = path ;
291
298
}
292
299
293
300
if (options .addAndroidDownloads .hasKey ("mime" )) {
@@ -333,7 +340,7 @@ public void run() {
333
340
appCtx .registerReceiver (this , new IntentFilter (DownloadManager .ACTION_DOWNLOAD_COMPLETE ), Context .RECEIVER_EXPORTED );
334
341
}else {
335
342
appCtx .registerReceiver (this , new IntentFilter (DownloadManager .ACTION_DOWNLOAD_COMPLETE ));
336
- }
343
+ }
337
344
future = scheduledExecutorService .scheduleAtFixedRate (new Runnable () {
338
345
@ Override
339
346
public void run () {
@@ -952,9 +959,9 @@ public void onReceive(Context context, Intent intent) {
952
959
}
953
960
954
961
// 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" ) ) {
956
963
try {
957
- String customDest = options . addAndroidDownloads . getString ( "path" ) ;
964
+ String customDest = customPath ;
958
965
boolean exists = new File (customDest ).exists ();
959
966
if (!exists )
960
967
throw new Exception ("Download manager download failed, the file does not downloaded to destination." );
0 commit comments