File Download

Hello to all, I am following a tutoria for listing the files in the server. after the file’s are shown in the table, can I do something in order to download it from the table. If I use file download I have to pick the file and always will be the same file. I would like for example click in the name of the file in the table and download it.
Thanks in advanced

You can send the ID of the file to your API action file which can then query on that ID to get the filename and pass back the file.

In that way I will able to download it? I will try

This should give you the info you need:

Excellent, I will do it, thanks

Looking at that tutorial, basically I have to click the button, then choose the file that I would like to download but if there a lot of documents in the file, will be hard to find it for some end users. Instead I would like to show the file name and then download directly from the file name linked to the file ID in the forder in the server with a server action. Is that possible? in that way the end user will always will download the correct file.

Do you know if there another way to perform this? I need to download a specific file.

In the App connect panel I place a download element, then in the path of the file that has been generate where show all the files in the forder I make a dinamic event / mouse click and choose the download element. the problem is that when try to download says that there no permission

Let’s say you have a table containing your download files and they are all stored in the /downloads folder. You could create an API script which returns the filename based on the ID sent to it. Then, on the page, add something like this:

<a href="/downloads/{{connDownload.data.queryFiles.filename}}" target="_blank">Download file</a>

This means the path to the file is easily found by the visitor which, it sounds like, won’t be a problem to you.

Is that what you’re after?

To add to @sitestreet answer, you need to add the download attribute instead of setting target blank.

<a dmx-bind:href="'/downloads/' + connDownload.data.queryFiles.filename" download>Download file</a>
1 Like

@Teodor’s is a much better solution so go with that. :+1:

Excellent, I will try this. I will post my results thanks

1 Like

I need to change where says /download/ with my full path correct? Also Can I place that code in a buttom, file name or file path in the table that I just generate correct?

Yes.

You can put the <a> tag anywhere. You’ll need to replace the dynamic code but Wappler makes it easy to insert it using the dynamic bindings.

Thanks, I will search for how to do the dynamic binding, looks not dificult.
Thanks

1 Like