Download binary data in POST request to a file

Some progress. I’ve added the line {:ok, body, conn} = Plug.Conn.read_body(conn) below

  def process(conn, params) do
    IO.inspect params, label: "params for 'process'"
    {:ok, body, conn} = Plug.Conn.read_body(conn)
    IO.inspect body, label: "BODY"
    conn |> render("pdf.json", url: "OK")
  end

Now I am seeing data:

[ debug] Processing with Koko.Web.PrintController.process/2
Parameters: %{“title” => “harmonic_oscillator!!”}
Pipelines: [:api]
params for ‘process’: %{“title” => “harmonic_oscillator!!”}
BODY: <<105, 109, 97, 103, 101, 47, 109, 97, 115, 115, 95, 115, 112, 114, 105, 110,
103, 45, 102, 100, 97, 99, 46, 112, 110, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …>>
[info] Sent 200 in 7ms