Phoenix.Controller.send_download/3

Parsed documentation:
View on GitHub
Sends the given file or binary as a download.

The second argument must be `{:binary, contents}`, where
`contents` will be sent as download, or`{:file, path}`,
where `path` is the filesystem location of the file to
be sent. Be careful to not interpolate the path from
external parameters, as it could allow traversal of the
filesystem.

The download is achieved by setting "content-disposition"
to attachment. The "content-type" will also be set based
on the extension of the given filename but can be customized
via the `:content_type` and `:charset` options.

## Options

  * `:filename` - the filename to be presented to the user
    as download
  * `:content_type` - the content type of the file or binary
    sent as download. It is automatically inferred from the
    filename extension
  * `:charset` - the charset of the file, such as "utf-8".
    Defaults to none
  * `:offset` - the bytes to offset when reading. Defaults to `0`
  * `:length` - the total bytes to read. Defaults to `:all`

## Examples

To send a file that is stored inside your application priv
directory:

    path = Application.app_dir(:my_app, "priv/prospectus.pdf")
    send_download(conn, {:file, path})

When using `{:file, path}`, the filename is inferred from the
given path but may also be set explicitly.

To allow the user to download contents that are in memory as
a binary or string:

    send_download(conn, {:binary, "world"}, filename: "hello.txt")

See `Plug.Conn.send_file/3` and `Plug.Conn.send_resp/3` if you
would like to access the low-level functions used to send files
and responses via Plug.
Suggestions:
Please help! Open an issue on GitHub if this assessment is incorrect.