ammarahm-ed/react-native-scoped-storage

Questions about Read/Write access

brunofariasd opened this issue · 2 comments

Hello, thx for awesome lib. I'm having a problem using this. My question is if using the function openDocumentTree i will be able to use another library that i will have read and write access without any problem.

Example:

Using openDocumentTree in path:
"/storage/emulated/0/Android/media",

this return
{"lastModified": 1641555076000, "name": "media", "path": "/storage/emulated/0/Android/media", "type": "directory", "uri": "content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia"}

So, this means that I will have read and write access to the above path and all its subdirectories ? I'm trying to use this library to get the permissions, and soon after I'll use another lib (RNFetchBlob) to read files in 'Android/Media/....Statuses' from Whatsapp Path.

I'm using:

"react-native-blob-util": "^0.13.17",
"react-native-scoped-storage": "^1.9.1",
"react-native": "0.66.3",

Thx a lot.

@brunofariasd You cannot use another library. You will have to use this library to read/write files to the given uri. Remember that you cannot use the path to read/write but only the uri.

If some other library supports reading/writing to a uri, it might be possible but I don't think any library supports it.

@brunofariasd You cannot use another library. You will have to use this library to read/write files to the given uri. Remember that you cannot use the path to read/write but only the uri.

If some other library supports reading/writing to a uri, it might be possible but I don't think any library supports it.

So, another question is when granting access to the path "/storage/emulated/0/Android/media", with return:
{"lastModified": 1641555076000, "name": "media", "path": "/storage/emulated/0/Android/media", "type": "directory", "uri": "content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia"}

Does this also give me access to your subdirectories ? When I run the function STAT in URI:

ScopedStorage.stat('content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsapp%2FMedia%2F.Statuses') .then(res => { console.log(res); }) .catch(res => { console.log(res); });

this return:

LOG {"lastModified": 0, "name": null, "type": "file", "uri": "content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsapp%2FMedia%2F.Statuses"}

But when i run LISTFILES this return:

[Error: 'content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsapp%2FMedia%2F.Statuses'is not a directory.]

Listfiles works correctly when choosing path .statuses ('/storage/emulated/0/android/media/com.whatsapp/whatsapp/media/.statuses'), but it doesn't work when i select some directories above.