Maybe the Load? Or the Progress? But progress you only delete at 99% or 100%
You can delete a file while the download is in progress, because Linux only truly deletes the file once it's no longer open (if you want the technical explanation it's something related with inodes)
However, the correct methodology would perhaps shift the responsability to delete the file server-side, at cron for example. You would delete files older than 15 minutes or something. You could prefix the filename with the current Unix timestamp. Or use a temporary folder (also a Linux technical term), but I don't know how that works, especially with Wappler on the mix
I recently setup a similar process where I delete the CSV file from the server after it has been downloaded. In my case, I'm using Server Connect Route to download the file instead of the dmx-download component.
There are 2 server connects - one to export/download the file (server connect route) and another to delete the CSV file on the server.
On success of the export/download SC, I run an inline flow to download the CSV and then run the file delete SC by passing the CSV's filename.
I've put a trash can icon on the page if a file exists and the user clicks it to delete it. This only really works for an admin area where the site owner knows that leaving a file there is a security risk so they make sure they click the icon. But I prefer the idea of doing it automatically 15 mins after it was created so you don't rely on anyone having to manually click something.
Wow, that inline flow is pretty gnarly!
I love the idea though @guptast , and I was thinking something pretty similar this evening about having the wait, but I think I’ll use a page flow.
I added wait to ensure that the file was not deleted before it had been downloaded. It doesn't add any wait for the user to finish the download process because the inline flow is running after the export/download SC has been successfully executed.
This would fail/stop the download if it takes more than 5 seconds to download.
Better option is to run a scheduler and delete files that are x-mins older, every few minutes.
Another option would require a custom JS implementation to download the file and then invoke browser download. Here, you may call the delete SC after JS download is completed, as it would not affect the browser download.