Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

Uploading and downloading files

Are you new here?

Anvil is a tool for building full-stack web apps with nothing but Python and a drag-and-drop designer. Learn more on our website, or sign up and try it yourself -- it's free!

Uploading

Files can be loaded into the browser using the FileLoader component.

To upload them to the back-end, simply pass the FileLoader’s file property as an argument to a server function.

The uploaded file will be a Media object. These can be stored directly in the Data Tables in a Media column.

Downloading

The Media object can be retrieved from Data Tables in the same way as you would a string, integer or other data type.

When the Media object is retrieved, it will still be a Media object; its format does not change from when it was originally loaded into the browser.

Media objects have a url property containing a URL that the user can access to download the file. Set this as a Link component’s url to give the user a clickable link that downloads the file. You can also automatically redirect the user to this URL as you would any other.