Download Media

marimo.download(data: str | bytes | BytesIO | BufferedReader, filename: str | None = None, mimetype: str | None = None, disabled: bool = False, *, label: str = 'Download') Html

Show a download button for a url, bytes, or file-like object.

Examples.

download_txt = mo.download(
    data="Hello, world!".encode("utf-8"),
    filename="hello.txt",
    mimetype="text/plain",
)

download_image = mo.download(
    data=open("hello.png", "rb"),
)

Args.

  • data: The data to download. Can be a string (interpreted as a URL), bytes, or a file opened in binary mode.

  • filename: The name of the file to download. If not provided, the name will be guessed from the data.

  • mimetype: The mimetype of the file to download, for example, (e.g. “text/csv”, “image/png”). If not provided, the mimetype will be guessed from the filename.

Returns.

An Html object for a download button.