react-native-fs: ENOENT: open failed: EACCES (Permission denied)
I’m getting this error whilst trying to open files in the directory ExternalDirectoryPath
.
I have seen that others have fixed it by targeting a lower SDK version (29 max) so that they can opt out of scoped storage.
This isn’t working for me consistently and after reading the android docs it seems this shouldn’t be causing any issue, we shouldn’t even need to request permissions.
For reference ExternalDirectoryPath
in RNFS returns the same as androids getExternalFilesDir()
method which is meant to not require permissions in most cases.
Anyone experienced this?
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 15
Hello. Do you guys have any solution to resolve this problem?
@Sid-Turner-Ellis My use case is The app creates a folder say “MyFolder” then app creates a file using
"RNFS.writeFile"
method. Since the file was created from the app itself app can read it. In the second case if the app downloads a file into the same folder path"MyFolder"
, the app can still read that file.In the last case if the user copy pastes a new file into
"MyFolder"
folder, then app cannot access it. This is what i am calling as manually added files. Even this is possible for android version 10 and below. In Android version 11 and above we cannot read files where the owner is not the app. in the above first 2 use cases the owenr of the files would be app so it can access it. In the current case since file was manually added to the folder the app is not the ownner of it which is why i am getting this error :"EACCES (Permission denied)"
Is there any way we can read/access such files where app is not the owner in android version 11 and above.
Folder is created in this path
RNFS.ExternalStorageDirectoryPath + '/Documents'+'/MyFolder'
@dmsierra11 I’m going to be looking into this shortly, I’m probably going to switch to a different module that is better contained.
Let me know if you find a solution
@Sid-Turner-Ellis have you found a solution? I am experiencing the same issue