react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Content URI directory support

Open LitileXueZha opened this issue 3 years ago • 3 comments

When I pick a single file, it works fine:

const res = await DocumentPicker.pick();
const content = await fs.readFile(res[0].uri);
// good

When I pick a directory, it does not work:

const res = await DocumentPicker.pickDirectory();
const dirs = await fs.readDir(decodeURIComponent(res.uri)); // decode the uri or it will throw a unsupported error
// not worked, throw a error: Permission Denial...ACTION_OPEN_DOCUMENT...

I see the same problem in this PR, but I don't konw how to do.

Environments:

Android 8.0
[email protected]
[email protected]
[email protected]

LitileXueZha avatar Jan 12 '22 14:01 LitileXueZha

same problem

sky0014 avatar Jan 30 '22 08:01 sky0014

Also test RNFS.stat with file and directory:

const result = await RNFS.stat(file);
console.log(result);
// Error: File does not exist

const result = await RNFS.stat(dir)
console.log(result);
// Error: Unsupported Uri content://com.android.externalstorage.documents/tree/primary%3A...

now I am wondering why readFile is work. in another issue #756

env:

Android 12
"react": "17.0.2",
"react-native": "0.67.2",
"react-native-document-picker": "^8.0.0",
"react-native-fs": "^2.19.0"

gj94gj94ao4 avatar Feb 24 '22 14:02 gj94gj94ao4

rn-fetch-blob works for me, ref to https://github.com/itinance/react-native-fs/issues/756#issuecomment-554937928

flyskywhy avatar Mar 22 '22 06:03 flyskywhy