itinance / itinance/react-native-fs

Getting EACCES (Permission denied) for manually added files for android version 11 and above. sdk version 30 and above

Open
#1,181 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Hi i am able to access files external directory files using following path.
`RNFS.ExternalStorageDirectoryPath + '/Documents/myFolder'`

I am able to create folder and files in this path and also able to read them.

But if i try to add a file manually into the same path and then the read fails with the error "EACCES (Permission denied)".

I checked the permission of both the files, and both manually and programatically created files have same access.
I am stuck here to resolve this issue like forever now. what could be the issue with manually added files ?

```
const folderPath=RNFS.ExternalStorageDirectoryPath + '/Documents/myFolder';
var fileSearchString = '/test.txt';
var finalFileToSearch = folderPath + fileSearchString;

RNFS.readDir(folderPath)
.then(result => {
console.log('GOT RESULT', result);

// stat the first file
return Promise.all([RNFS.stat(result[0].path), result[0].path]);
})
.then(statResult => {
if (statResult[0].isFile()) {
// if we have a file, read it


return RNFS.readFile(finalFileToSearch, 'utf8');
}
return 'no file';
})
.then(contents => {
// log the file contents
console.log('File Contents : ', contents);

})
.catch(err => {
console.log('ERROR >>>> ', err.message, err.code);

});
```

**This above is happening only for android SDK api >29 / android 11 and above. I am able to access files for android 10 and below.**

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the supplied RNFS.readDir/stat/readFile example on Android API 30 or newer, comparing manually added and programmatically created files under ExternalStorageDirectoryPath/Documents/myFolder. Trace the Android storage behavior involved and verify a resolution or documented limitation for reading the manually added file.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.