SAF: App Inventor implementation of Storage Access Framework

Many thanks, Anke and vKnow360, Anke I've run your method and it worked for me and gave me a better insight into how SAF works.

It seems necessary to run the 'Open Single Document' function each time to read the file, which means a user intervention. which is not too inconvenient for my application. Is this a security requirement for Google?

When I use 'Open Document Tree' and copy the file URI from the 'List Files' component (example A in my first email) it's possible to open any directory and to make multiple reads without having to reopen the document tree each time. Is this likely to be considered a security breach by Google?

1 Like

If your app is only intended *for private use" you can have a look to How to request and grant MANAGE_EXTERNAL_STORAGE permission

1 Like

No, you should try taking persistable uri permission.

For that you must take persistable uri permission.

1 Like

Thank you vKnow360, I will try the persistable permission to see how it works

1 Like

Thank you Patel that looks like a very useful link to study. However, my App is intended for public use and the example I gave looks as if it might breach Google guidelines but it maybe the persistable permission function works by modifying the file being read? I'll keep on testing until I understand the SAF functions better.

1 Like

You can take persistable permission in this way, but i can read file, no write.

Why this block runs well with apk but does not with companion ?

Please upload the aia so that I can take a look.
Though if it works in apk, its functionality in companion shouldn't be a concern.

2 Likes

Find attached aia, I'm using companion 2-62u, error message "media is read only"
Saf_1.aia (60.2 KB)

Works fine with Companion on Android 11 (even with the non-current extension version).

Current version

I am facing some problem with this SAF thing.
My end goal is to read a pdf from Documents folder and upload it to Firebase Storage. The problem I am facing is after picking the file from Documents folder and coverting its URI to path to upload it to Firebase Storage as it accepts File Paths only. I got path as /sdcard/..... which is prompted as No such file or directory while uploading to Firebase Storage.

Sorry actually I am explaining my post but unfortunately ended up posting it. Edited my issue please help me with it if you could.

can you post a link to your companion apk ?

I can see all text files with this block
block1
but I want see only csv

Try setting text/csv as extra mime type.

2 Likes

text/csv was my first attempt with no results

Did you solve that? I have exactly the same issue, cannot upload CSV files. I tried like this, but all csv files in my storage show greyed out:
grafik

ah, it worked now for me with the following block (no clu which of the mime types in the block worked and I am too lazy to check one by one):
grafik

4 Likes