Skip to content

Commit 59d3adf

Browse files
author
Ron Radtke
committed
fixing it so it works
1 parent 8ca5aea commit 59d3adf

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import android.os.StatFs;
1010
import android.util.Base64;
1111

12+
import androidx.annotation.NonNull;
13+
1214
import com.facebook.react.bridge.Arguments;
1315
import com.facebook.react.bridge.Callback;
1416
import com.facebook.react.bridge.Promise;
@@ -358,11 +360,15 @@ static Map<String, Object> getSystemfolders(ReactApplicationContext ctx) {
358360

359361
return res;
360362
}
363+
361364
/**
362365
* Static method that returns legacy system folders to JS context (usage of deprecated functions since these retunr different folders)
363366
*
364367
* @param ctx React Native application context
365368
*/
369+
370+
@NonNull
371+
@SuppressWarnings("deprecation")
366372
static Map<String, Object> getLegacySystemfolders(ReactApplicationContext ctx) {
367373
Map<String, Object> res = new HashMap<>();
368374

@@ -833,7 +839,7 @@ static void hash(String path, String algorithm, Promise promise) {
833839
promise.reject("EINVAL", "Invalid algorithm '" + algorithm + "', must be one of md5, sha1, sha224, sha256, sha384, sha512");
834840
return;
835841
}
836-
842+
837843
path = ReactNativeBlobUtilUtils.normalizePath(path);
838844

839845
File file = new File(path);

android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilMediaCollection.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ private static String getRelativePath(MediaType mt, ReactApplicationContext ctx)
6969
if (mt == MediaType.Download) return Environment.DIRECTORY_DOWNLOADS;
7070
return Environment.DIRECTORY_DOWNLOADS;
7171
} else {
72-
if (mt == MediaType.Audio) return ReactNativeBlobUtilFS.getExternalFilesDirPath(ctx, Environment.DIRECTORY_MUSIC);
73-
if (mt == MediaType.Video) return ReactNativeBlobUtilFS.getExternalFilesDirPath(ctx, Environment.DIRECTORY_MOVIES);
74-
if (mt == MediaType.Image) return ReactNativeBlobUtilFS.getExternalFilesDirPath(ctx, Environment.DIRECTORY_PICTURES);
75-
if (mt == MediaType.Download) return ReactNativeBlobUtilFS.getExternalFilesDirPath(ctx, Environment.DIRECTORY_DOWNLOADS);
76-
return ReactNativeBlobUtilFS.getExternalFilesDirPath(ctx, Environment.DIRECTORY_DOWNLOADS);
72+
if (mt == MediaType.Audio) return ReactNativeBlobUtilFS.getLegacySystemfolders(ctx).get("LegacyMusicDir").toString();
73+
if (mt == MediaType.Video) return ReactNativeBlobUtilFS.getLegacySystemfolders(ctx).get("LegacyMovieDir").toString();
74+
if (mt == MediaType.Image) return ReactNativeBlobUtilFS.getLegacySystemfolders(ctx).get("LegacyPictureDir").toString();
75+
if (mt == MediaType.Download) return ReactNativeBlobUtilFS.getLegacySystemfolders(ctx).get("LegacyDownloadDir").toString();
76+
return ReactNativeBlobUtilFS.getLegacySystemfolders(ctx).get("LegacyDownloadDir").toString();
7777
}
7878
}
7979

0 commit comments

Comments
 (0)