itinance / react-native-fs

Native filesystem access for react-native
MIT License
4.89k stars 954 forks source link

RNFS.readDir(path) only returns folders in directory files are excluded #1208

Open MianIbrarHussain opened 6 months ago

MianIbrarHussain commented 6 months ago

I have been using different libraries but none of them is fetching files all of them only return folders. I am working on file manager app for which access to all files in storage is necessary. If anyone could tell me why react-native-fs or react-native-blob-util only return folders and not files in them? If anybody have any suggestions I am all ears.

Valentine-Mario commented 6 months ago

I also experienced the same issue when I used ExternalStorageDirectoryPath but DocumentDirectoryPath list all files and folders

chinmay4github1987 commented 2 months ago

Same thing happening for me as well directory files are excluded

arthurDz commented 1 month ago

Same thing happening for me as well directory files are excluded

I also faced same issues but figured it was not the issue of RNFS.readDir function but due to change in the way permissions are handled from android 11(API level 30). Android 11 introduced scoped storage, which restricts access to external storage and requires apps to use the MediaStore API or the Storage Access Framework (SAF) for accessing files. So, from Android 11, the READ_EXTERNAL_STORAGE permission is not required for accessing media files. Instead, you should use the READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, or READ_MEDIA_AUDIO permissions, depending on the type of media you're accessing. Hope it helps, if it does then leave a thumbs up or if not then please mention the API level/Android version on which you are facing this issue then I will be able to help more.