Skip to content

Instantly share code, notes, and snippets.

@gcavanunez
Created December 18, 2022 03:59
Show Gist options
  • Save gcavanunez/a93a462536a5f6b4a040c8eb4994d032 to your computer and use it in GitHub Desktop.
Save gcavanunez/a93a462536a5f6b4a040c8eb4994d032 to your computer and use it in GitHub Desktop.
Streaming a file from elixir
def sup(conn, _params) do
conn = conn
|> put_resp_header("content-type", "audio/mp3")
|> send_chunked(200)
File.stream!("priv/static/assets/sample4.mp3", [], @chunk_size)
|> Enum.into(conn)
end
# https://stackoverflow.com/questions/37544655/elixir-stream-audio-to-users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment