From c90461495f27449ec23162b30a0d918282a0e30f Mon Sep 17 00:00:00 2001 From: Nathan Nahi Date: Thu, 12 May 2022 22:49:55 +1200 Subject: [PATCH 1/3] Expose MoviesDirectoryPath for Android --- FS.common.js | 1 + android/src/main/java/com/rnfs/RNFSManager.java | 2 ++ index.d.ts | 1 + windows/RNFS/RNFSManager.cs | 6 ++++++ 4 files changed, 10 insertions(+) diff --git a/FS.common.js b/FS.common.js index 62b7ba73..262f8d56 100755 --- a/FS.common.js +++ b/FS.common.js @@ -626,6 +626,7 @@ var RNFS = { TemporaryDirectoryPath: RNFSManager.RNFSTemporaryDirectoryPath, LibraryDirectoryPath: RNFSManager.RNFSLibraryDirectoryPath, PicturesDirectoryPath: RNFSManager.RNFSPicturesDirectoryPath, + MoviesDirectoryPath: RNFSManager.RNFSMoviesDirectoryPath, FileProtectionKeys: RNFSManager.RNFSFileProtectionKeys }; diff --git a/android/src/main/java/com/rnfs/RNFSManager.java b/android/src/main/java/com/rnfs/RNFSManager.java index 351ac066..9587bdc9 100755 --- a/android/src/main/java/com/rnfs/RNFSManager.java +++ b/android/src/main/java/com/rnfs/RNFSManager.java @@ -48,6 +48,7 @@ public class RNFSManager extends ReactContextBaseJavaModule { private static final String RNFSExternalDirectoryPath = "RNFSExternalDirectoryPath"; private static final String RNFSExternalStorageDirectoryPath = "RNFSExternalStorageDirectoryPath"; private static final String RNFSPicturesDirectoryPath = "RNFSPicturesDirectoryPath"; + private static final String RNFSMoviesDirectoryPath = "RNFSMoviesDirectoryPath"; private static final String RNFSDownloadDirectoryPath = "RNFSDownloadDirectoryPath"; private static final String RNFSTemporaryDirectoryPath = "RNFSTemporaryDirectoryPath"; private static final String RNFSCachesDirectoryPath = "RNFSCachesDirectoryPath"; @@ -994,6 +995,7 @@ public Map getConstants() { constants.put(RNFSDocumentDirectoryPath, this.getReactApplicationContext().getFilesDir().getAbsolutePath()); constants.put(RNFSTemporaryDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath()); constants.put(RNFSPicturesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()); + constants.put(RNFSMoviesDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).getAbsolutePath()); constants.put(RNFSCachesDirectoryPath, this.getReactApplicationContext().getCacheDir().getAbsolutePath()); constants.put(RNFSDownloadDirectoryPath, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath()); constants.put(RNFSFileTypeRegular, 0); diff --git a/index.d.ts b/index.d.ts index da3fa7de..07c7dab9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -291,4 +291,5 @@ export const ExternalStorageDirectoryPath: string export const TemporaryDirectoryPath: string export const LibraryDirectoryPath: string export const PicturesDirectoryPath: string +export const MoviesDirectoryPath: string export const FileProtectionKeys: string diff --git a/windows/RNFS/RNFSManager.cs b/windows/RNFS/RNFSManager.cs index cf433bd0..a1f83043 100644 --- a/windows/RNFS/RNFSManager.cs +++ b/windows/RNFS/RNFSManager.cs @@ -99,6 +99,12 @@ public override IReadOnlyDictionary Constants constants.Add("RNFSPicturesDirectoryPath", pictures); } + var movies = GetFolderPathSafe(() => KnownFolders.VideosLibrary); + if (movies != null) + { + constants.Add("RNFSMoviesDirectoryPath", movies); + } + return constants; } } From c996f27d56fa57ed487a600a0e5ea3dec5635905 Mon Sep 17 00:00:00 2001 From: Nathan Nahi Date: Thu, 12 May 2022 23:00:48 +1200 Subject: [PATCH 2/3] Add VideosLibrary Path --- windows/RNFS.Net46/RNFSManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/windows/RNFS.Net46/RNFSManager.cs b/windows/RNFS.Net46/RNFSManager.cs index 3fbb078e..a4d9f08e 100644 --- a/windows/RNFS.Net46/RNFSManager.cs +++ b/windows/RNFS.Net46/RNFSManager.cs @@ -80,6 +80,7 @@ public override IReadOnlyDictionary Constants { "RNFSDocumentDirectoryPath", KnownFolders.Documents.Path }, { "RNFSTemporaryDirectoryPath", KnownFolders.InternetCache.Path }, { "RNFSPicturesDirectoryPath", KnownFolders.CameraRoll.Path }, + { "RNFSPicturesDirectoryPath", KnownFolders.VideosLibrary.Path }, { "RNFSFileTypeRegular", 0 }, { "RNFSFileTypeDirectory", 1 }, }; From 6c7473ef1182181c559be0e4adefb5135950fc08 Mon Sep 17 00:00:00 2001 From: Nathan Nahi Date: Thu, 12 May 2022 23:04:13 +1200 Subject: [PATCH 3/3] Fix bad copy-paste job --- windows/RNFS.Net46/RNFSManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/RNFS.Net46/RNFSManager.cs b/windows/RNFS.Net46/RNFSManager.cs index a4d9f08e..2b9d85f3 100644 --- a/windows/RNFS.Net46/RNFSManager.cs +++ b/windows/RNFS.Net46/RNFSManager.cs @@ -80,7 +80,7 @@ public override IReadOnlyDictionary Constants { "RNFSDocumentDirectoryPath", KnownFolders.Documents.Path }, { "RNFSTemporaryDirectoryPath", KnownFolders.InternetCache.Path }, { "RNFSPicturesDirectoryPath", KnownFolders.CameraRoll.Path }, - { "RNFSPicturesDirectoryPath", KnownFolders.VideosLibrary.Path }, + { "RNFSMoviesDirectoryPath", KnownFolders.VideosLibrary.Path }, { "RNFSFileTypeRegular", 0 }, { "RNFSFileTypeDirectory", 1 }, };