Does expo-file-system support reading of directories and subdirectories located on an external USB drive?

  1. SDK Version: 44
  2. Platforms(Android/iOS/web/all): android

My app is trying to read files from a certain directory from a plugged in external USB drive.
When the user plugs in the USB drive into the phone, my app should be able to read the directories and files and perform some action. I’m trying to use the files-system libraries but am having trouble getting this to work.

So far I’m able to read a top level of a directory based on user given permission to that directory. So for example I can get files/directories by using the API:

StorageAccessFramework.readDirectoryAsync(“content://com.android.externalstorage.documents/tree/primary%3A”);

“content://com.android.externalstorage.documents/tree/primary%3A/document/primary%3AAndroid”,“content://com.android.externalstorage.documents/tree/primary%3A/document/primary%3AMusic”,“content://com.android.externalstorage.documents/tree/primary%3A/document/primary%3APodcasts”,
…etc.

However, when I try to use the same API to read into a subdirectory inside, such as:
StorageAccessFramework.readDirectoryAsync(“content://com.android.externalstorage.documents/tree/primary%3AMusic”);

It does not return files from the Music subdirectory, but still return the same list of files as the previous call.

Does anyone know why this is? Does gaining permission from the user on directory A, give the app permission for it and all subdirectories? I cannot imagine that it’s due to the permission where the user has to explicitly give permission (via the Android UI) to each subdirectory that the app accesses.

I’ve also tried using the FileSystem.readDirectoryAsync() call and it gives error msg saying I should use StorageAccess API instead.

Another way to phrase the question is:
Does gaining permission through the StorageAccessFramework.requestDirectoryPermissionsAsync() API give the app access to it and all its subdirectories, OR does it only give 1-level of access?

Any ideas?

Thanks
Edward

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.