Skip to content
Discussion options

You must be logged in to vote

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

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pau-riosa
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #786 on July 11, 2025 19:52.