Programming Phoenix LiveView: Live Upload Match Error

Book: Programming Phoenix LiveView, page 142 (157/378), file lib/pento_web/live/product_live/form_component.ex, in the function below:

defp handle_progress(:image, entry, socket) do
    :timer.sleep(200)

    if entry.done? do
      # here instead of {:ok, path} I changed to path only, and it worked
      path =
        consume_uploaded_entry(
          socket,
          entry,
          &upload_static_file(&1, socket)
        )

      {:noreply,
       socket
       |> put_flash(:info, "file #{entry.client_name} uploaded")
       |> assign(:image_upload, path)}
    else
      {:noreply, socket}
    end
  end

Let me know if this is correct, because here It only worked when I changed.

Docs:
https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#consume_uploaded_entry/3-examples

4 Likes