Genie Discord forum

Author AvatarJim
11/13/2023, 5:18:12 PM

I'm new to using Genie (or anything similar) and I need to send some files to the web browser that is running the app.

I'm generating the files no problem, but after pooring over the docs and forums I still can't figure out how to do this. What am I missing?

Author AvatarPere
11/13/2023, 5:38:25 PM

Try storing the files in the public/ folder, (create it first) and then add a link to the file on your page like , or a(href="/filename.zip")in Julia.

https://learn.genieframework.com/docs/guides/adding-dynamic-pages#including-static-assets

Author AvatarJim
11/13/2023, 6:47:21 PM

I'm still confused by this, I have a button that generates these files and I want them to be downloaded once generated. Is this possible or should I use a link that the user clicks on?

Author AvatarPere
11/14/2023, 1:31:16 PM

That's a little more difficult to do as it requires adding some javascript. You'd have to add a link to the page. When the file is generated, make the link point to the file and trigger a download. The triggering is done via a Javascript watcher, which check the href attribute of the link and clicks it when it changes. I've added an example for this to the docs

https://learn.genieframework.com/docs/examples/reactive-ui/trigger-download

Author AvatarJim
11/14/2023, 2:41:27 PM

Awesome, that did the trick. Thank you so much!

Author Avatarhhaensel
12/5/2023, 5:54:42 PM

We have a much smoother way for this kind of task now. See https://github.com/GenieFramework/StippleDownloads.jl