Created
December 18, 2022 03:59
-
-
Save gcavanunez/a93a462536a5f6b4a040c8eb4994d032 to your computer and use it in GitHub Desktop.
Streaming a file from elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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