Here is a way to download multiple files to the ASD and replace the files that have already been download before:
Here you can find a test app (aia):
your understanding is incorrect...
as you can see from the overview
the question is, are the files in the /Download
folder you like to access have been stored by your own app or not? For 1) use the file component, for 2) use the SAF extension
Taifun
Thanks for you help, I'm grateful.
I checked your test app and it's working but I struggle with one thing, which is to find the exact URL of the file I need to import.
In fact, my user can, with just a click, "share" a file or all the files in a zip file with any share solution installed on his phone. This works great.
But the reverse is much more complicated.
Is there a possibility for the user to receive a file as an attached file to a mail, and to put this file in the ASD through the app ? If not, how can I put the file on the internet with a direct URL that downloadtoASD will be able to cope with ? most cloud services give links to webpage with buttons to click to download the file :-/
What does that mean? Where does the URL(s) come from, who knows about it?
(Questions upon questions )
Hence my suggestion again:
to read an email there is the IMAP extension available
however it looks like extracting an attachment is not available there?
Taifun
Trying to be as precise as possible: I want the user to be able to import a file, either from the /download folder, or directly from internet, into the ASD so that the app uses those files on the next initializing.
- my first idea would be a file picker, with access to the /download folder. Unfortunately, this seems not possible anymore from Android 11. I tried with no success.
- so the second idea is direct download from the internet into the ASD, using DownloadtoASD extension. But I struggle with the correct URL to feed into the textbox before clicking the "import" button.
For example, if I put the file on my google drive, with a link open to all users, like this one:
ListeJuments (1).csv - Google Drive
The URL isn't correct I have to edit the URL for the download to work. I made it work with Google Drive Direct Link Generator to get a direct link but it's frankly unusable for a normal user :-/
Is there nothing simpler ?
So if all the URLs are from you, what's the problem? And where do the files in the /Download folder come from that cannot be accessed on Android 11+?
In other words, it's still not clear to me what exactly is supposed to happen and how.
The problem is, my app is used by several hundreds of users. The how-to manual to import data cannot be :
First put it on your drive
Then share it to anybody
Then convert the URL using some online generator
Then send the link to your phone
Then paste the link in the text box
That's not practical at all ?!
About the download option, the file would come as an attached file to a received email. When I click on it in my email app on the phone it will go in the download folder. Is there any possibility for my app to copy it to the ASD for import ?
You appear to be making life unnecessarily difficult for yourself and your users...
If it were me, I would not be bothering with files, I would be downloading data to the app, storing it in local storage (tinydb) and then providing it for users, updating the data in tinydb as required.
But the data has to be resistant to a phone change or crash. It's data my user usually keep on precious written form, for years.
If they are to put it in an app, for a better usage of this data, this can't be a case where they risk to lose the data if they lose the phone.
And the data is the user's data ! Not mine !
this is still possible, for example using the file extension and its FileList method
and as already mentioned earlier
the question is, are the files in the
/Download
folder you like to access have been stored by your own app or not? For 1) use the file component, for 2) use the SAF extension
Taifun
If they lose the phone, they would lose the file that also holds the data....? In fact the data is possibly safer stored in a private directory (where tinydb stores its data) than in a "public" /Downloads folder in a csv file?
If you just download the data surely/certainly you would store it online/elsewhere for backup / security purposes?
The data is not downloaded. It's saved in the app by the user.
The problem is importing / exporting this data.
Exporting is easy : a share component. Importing ?
Title of this topic....
Download a file to ASD and replacing a file already there
.
.
.
.
Regardless, just trying to give you some food for thought
Edit :
The data is primarily saved by the user in the app.
I want the data to be exportable and importable to another phone using the same app.
The export part is simple, with a share block.
The import part is the problem.
Either the data arrives on the recieving phone through an incoming mail and it will be written on the download phone by the email app, so the problem will be to copy it to the ASD then : you say it would be possible with the SAF extension ?
Or the data is directly downloaded in the ASD by the app using the downloadtoasd extension.
Whence the title of this post.
Is it clearer ?
I confess to some shyness about the SAF extension and 233 answers on the thread :-/
It all seems such a struggle....
Why not use a google sheet as your datastore, with an apps script web app bound to the spreadsheet? Both/All devices can download the latest data and upload changes (if required). The spreadsheet can be private (restricted). No files needed, either end or in-between.... (this is a very simple example)
function doGet(e) {
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName('Sheet1');
var values = JSON.stringify(sh.getDataRange().getValues());
values = values.replace(/"([^"]*)'([^"]*)"/g, "$1\\'$2");
return ContentService.createTextOutput(values);
}
function doPost(e) {
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName('Sheet1');
sh.clearContents();
var arr = JSON.parse(e.postData.contents);
sh.getRange(1,1,arr.length,arr[0].length).setValues(arr);
return ContentService.createTextOutput('data uploaded');
}
Possible, but they will be always downloaded to ASD, as for now.
But that would require each user of my app to configure a Google sheets complete with a web app for the app to be able to store data here ?
That's not possible !
Each user has his own data.