joltup / rn-fetch-blob

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

Permission Denial on reading a file #601

Open LuigiMaestrelli opened 4 years ago

LuigiMaestrelli commented 4 years ago

I'm using react-native-document-picker to select some files.

After selecting a Google Drive file, I use the provided uri to read as base64 using RNFetchBlob.fs.readFile(fileUri, 'base64');

When reading the file I got this error

Error: Permission Denial: reading com.google.android.apps.docs.storagebackend.StorageBackendContentProvider uri content://com.google.android.apps.docs.storage/document/acc=1;doc=encoded=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX from pid=2062, uid=10288 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs

And then I tried selecting another file from my local storage (from Downloads folder) and got a similar issue:

Error: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/document/primary:Download/somefile.gif from pid=25027, uid=10288 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs

I'm checking for reading storage permission and it has permission... Am i missing something?

I'm testing on a OnePlus 5T Android 9 react-native: 0.62.2 rn-fetch-blob: 0.12.0

indranildutta06 commented 4 years ago

For now, you can have a temporary solution under tag of your Android Manifest file.

android:requestLegacyExternalStorage="true"

add this line in tag.