-
Is there any documentation how to consume a stream body coming from Tesla.Adapter.Finch? I'd like to consume a stream data and create a wav file from it. |
Beta Was this translation helpful? Give feedback.
Answered by
yordis
Jul 11, 2025
Replies: 2 comments
-
Could you do something like, defmodule AudioStreamer do
def client do
Tesla.client([
{Tesla.Middleware.BaseUrl, "https://audio-service.com"}
], {Tesla.Adapter.Finch, name: MyFinch})
end
def stream_to_wav_file(audio_url, output_path) do
case Tesla.get(client(), audio_url, opts: [adapter: [response: :stream]]) do
{:ok, %Tesla.Env{body: stream}} ->
File.open!(output_path, [:write, :binary])
|> write_stream_to_file(stream)
|> File.close()
{:ok, output_path}
{:error, reason} ->
{:error, reason}
end
end
end |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pau-riosa
-
Thank you for this one @yordis |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you do something like,