Download STL file upon Button Click

What I’m trying to do: I am building an app that allows the user to specify a mathematical expression on a specified domain, and then returns an stl file to the user, automatically downloading it to their machine. This is all being written within google colab

What I’ve tried and what’s not working: I initially tried using the colab command files.download within the function called by the button. This does not lead to any downloads happening on my machine. I then read the documentation on media objects, but couldn’t figure out a way to make it work with stl files.

If you can get the bytes out of the STL file, you can construct an Anvil media object as specified in the docs: Anvil Docs | Files, Media and Binary Data

That media object can be passed back to an Anvil client, and downloaded as per the docs: Anvil Docs | Files, Media and Binary Data

3 Likes