View Source Kino.Download (Kino v0.8.1)

A kino for downloading file content.

examples

Examples

Kino.Download.new(fn ->
  "Example text"
end)

Kino.Download.new(
  fn -> Jason.encode!(%{"foo" => "bar"}) end,
  filename: "data.json"
)

Kino.Download.new(
  fn -> <<0, 1>> end,
  filename: "data.bin",
  label: "Binary data"
)

Link to this section Summary

Functions

Creates a button for file download.

Link to this section Types

Link to this section Functions

Link to this function

new(content_fun, opts \\ [])

View Source
@spec new(
  (() -> binary()),
  keyword()
) :: t()

Creates a button for file download.

The given function is invoked to generate the file content whenever a download is requested.

options

Options

  • :filename - the default filename suggested for download. Defaults to "download"

  • :label - the button text. Defaults to the value of :filename if present and "Download" otherwise