joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

Not listing the files using rn fetch blob in react native [Error: Attempt to get length of null array] #631

Open iamthomasjames opened 3 years ago

iamthomasjames commented 3 years ago

I was trying to list all the files in a folder using rn fetch blob in react native. When i tried to list it i am getting an error saying

[Error: Attempt to get length of null array] here is the below code I have tried to list the files.


 try {
        var TRACK_FOLDER = RNFetchBlob.fs.dirs.DownloadDir + '/BlabberApp/';
        let files = await RNFetchBlob.fs.ls(TRACK_FOLDER)
        console.log(files);
      } catch (error) {
        console.log(error);
      }

Its working perfectly in system emulator and when i tested in real devices its force closing and throwing this error. I am pretty sure that i gave given storage permission for this but still I am getting this error.

Any help would be appreciable.

I am using the version : "rn-fetch-blob": "^0.12.0"

Thanks in advance :)

denizyesilirmak commented 3 years ago

same here.

dungle27 commented 3 years ago

Please help us fix this issue

TayyabaAslam3317 commented 3 years ago

This happens for Android API level 29 +. Works fine for API level 28.

redefinered commented 3 years ago

@TayyabaAslam3317 why?

fattahmuhyiddeen commented 2 years ago

same here

yashwant-dangi commented 2 years ago

Android 10 introduce a new storage paradigm called scoped storage. Due to this is not working. <application android:requestLegacyExternalStorage="true" ... > ... </application> in AndroidManifest.xml. This is a temporary solution.

For me after adding this block, it started working.

Original Answer: https://github.com/joltup/rn-fetch-blob/issues/700#issuecomment-732417928