Download a file to ASD and replacing a file already there

Hi,
I want to download a file in my ASD to replace the one (same name, same usage for the app) already there.
I use the Anke extension downloadtoASD which works great, thanks !
I tried at first the simple way by just the download block.
Unfortunately, the system saw that a file with the same name exist and renames the new file with a -1, which means the app keeps using the bad one.
So I decided to check if the file existed first, and delete it, and then download the new file:


But : it doesn't work. The new file still gets renamed.
I suspect it's a workflow problem : the app doesn't have the time to complete the deletion of the first file before downloading the new one.
If that's the problem, what can I do ? there is no When file deleted block, as far as I know. I could start a timer and wait for a second or so but that means artificially slowing the app.
Or is there a solution to force the downloading to overwrite any existing file ?

Hello Rigel

Try this: If the file exists = true, call a result Procedure to run the file delete function:

DeleteFile

1 Like

just wait for example only 100 milliseconds :grin:
the solution of @ChrisWard will have the same issue...
Taifun

1 Like

The blocks marked in yellow refer to the root directory of the external storage (and not to the ASD).

Try this:

2 Likes

I don't understand : Do you mean that the "Set Label Text to" block is enough to slow the flow for 500ms and allow for the download block to launch late enough ?

My blocks should make it clearer. So now just try these blocks and you will see that it works and that no duplicate csv file will be created (downloaded).

1 Like

... or this:

1 Like

It works, thanks a lot !
If I may : the set file scope to block : can I put it just once if I have several files to download or is it necessary everytime I delete then download the new file ?

Show your blocks.

2 Likes

First we need to clarify why the files should be downloaded again. Does something change in these files? If not, it is sufficient to query whether the file(s) have already been downloaded and, only if this has not yet happened, to download them.

1 Like

Like this:

1 Like

It is an export / import data feature in the app. The idea is to allow the user to export data to another phone for example. So yes, if he decides to do so, he will replace the data existing in the receiving phone with the data coming from the sending phones.
Due to storage restriction with android11 I understand the only way to do this is to download directly the data from the internet to the ASD with the app, the user can't pick a downloaded file in the download directory (which is VERY unfortunate in fact, because to guide the user to his file's exact url is tricky). But I don't know how to do it otherwise.

You can copy / move the downloaded files (from the ASD) to the /Download folder.

But I want to do the opposite ? Copy / move downloaded files from the /download folder to the ASD ?

Describe exactly what steps are to be taken.

  1. Do this -> event
  2. Do that -> event
  3. ...
    ...

The files are light .csv ones. The simplest way to do so would be for the sending user to send the files by mail (that I'm able to simply do so with a share bloc), and for the receiving user to click on the attached file in his mailbox, which will put the files in the download folder. And then, in the app, to select the files in the download folder and import them. But I understand that the download folder isn't accessible by the app for .csv files ?

I do not understand. Why don't you follow my suggestion to explain it step by step: 1. then 2. etc.

I don't understand that either. What is that supposed to mean?

Here is a way to download multiple files to the ASD and replace the files that have already been download before:

1 Like

Here you can find a test app (aia):