File download with dynamic link

How to achieve this on dynamic link inside repeat region?

You can pass the dynamic file name from the repeat to the download action, as a parameter.

May I have more specific instruction, because from the step above, the link to the file is static. I’ve tried to use $_GET to pass the dynamic file to the file path on click event e.g./assets/resources/{{$_GET.file}} but the route didn’t work.

First, in your server action create a get variable:

Use it in the download path:

Screenshot_6

The route that will be generated will include this get var as a parameter:

On the page, when you pick the route for the anchor button/link - just bind the value from your repeat using the dynamic data button:

Alright. I’ve followed the step without success. What I might have missed?


Annotation%202019-09-12%20150707

Annotation%202019-09-12%20145754
Annotation%202019-09-12%20150301
Annotation%202019-09-12%20150417

You need to use dynamic attributes - link, not a regular static href.

The link looks alright, but download doesn’t work. Just page flashing.


Annotation%202019-09-12%20151028

Please provide a link to your page, where i can check this.

@Teodor I’m not able to up the site at this moment. But just to make sure if this step also works with content / include routing page as in this case. Thanks.

I don’t see why it would not run … you can test it on a normal page to see also, but without a link to the page i can’t say what could be wrong.

Hi @Teodor I can confirm the method does work with routing page as well. I’ve tested on a fresh new page. It only problematic on the current page I work with. Once I’ve upped the page, would send the link to you to check. Thank you.

So just want to share, I’ve successfully diagnosed the problem. The reason the link didn’t work because it’s being called from a routing page inside routing with name i.e /insider/resource instead of just /resource. The solution is just by adding initial ../ to the link so it will omit /insider/ from the path. Mystery solved. :sweat_smile:

Annotation%202019-09-12%20225846

fix

Included “dmx-bind” before href tag
Wappler 3.1.0

Hey @Teodor,

I’m working in Node.js and followed along your tutorial and have done the following:




When I click on the link, I get the following:

{“status”:“404”,“message”:"/api/lease/download_lease/lease.pdf not found."}

However, when I hard code the file name in the file path:
image

The download works as expected.

I’m not super familiar with routing, so I could be wrong, but it seems that the routing isn’t working correctly. Or perhaps, the routing in Node.js is different, or I’m doing something wrong.

Your help would be appreciated.

yeah i also have a same issue dynamically file download giving error as page not found.

@nepatriot and @cdmx.licensing3 Did you manage to resolve the issue - also just getting a file not found at the correct path. Static file selects work, but as soon as I replace the static path and filename with a dynamic value, I get a file not found error.

@Teodor I followed your steps exactly (I hope…)

Url contains my whole path to the file(it is the black text section just for illustration):

No Luck this side. Can you maybe see what I am missing?