GitHub user breautek added a comment to the discussion: List subfolders and 
files of a folder (with SAF), Android 13+

> could i achieve this with the cordova-plugin-file (under Android API 34)?

Kind of, but not completely.

The main piece that is missing for your use case I think is the open document 
intent implementation. That's the system that provides the user the document 
view so that they can select a file. The file plugin can resolve `content://` 
paths and read from them, but using the file plugin itself, there is no way to 
obtain `content://` paths.

It also doesn't request permissions. When you use that system dialog so that 
the user can select content, the system will grant your app temporary read 
access to that file which expires when your app's activity closes. This means 
that the `content://` paths are only temporarily accessible so they cannot be 
persistently stored. So if you need permanent access to that content, that 
content needs to be copied to your app's storage data.

There is also a bug that prevents `content://` paths to produce DOM-usable urls 
so that content resources can be used in `<img>` tags or other HTML media 
elements. There is a PR proposal to fix this issue via 
https://github.com/apache/cordova-plugin-file/pull/629 though.

I've been looking into making other Apache plugins like the camera and 
media-capture plugins return `content://` paths instead of a `file://` path 
which has a number of advantages. So I've been doing quite a bit testing on 
using `content://` paths in the file plugin and most of it works today, 
assuming that:

1. You're just trying to do read operations on the content
2. You've obtained the `content://` path freshly in a way that the OS will give 
you read access to that content
3. Using the FileReader APIs should work, or using the `copyTo` API to copy to 
app's local data storage should also work.

So in otherwords today, if your SAF plugin can provide you a `content://` path 
with read access granted, the file plugin should be able to be used to read or 
copy that data. The only thing that won't work is trying to produce a 
DOM-usable URL which requires the 
https://github.com/apache/cordova-plugin-file/pull/629 fix.

GitHub link: 
https://github.com/apache/cordova/discussions/494#discussioncomment-10614276

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to