Hi, please forgive me if I am missing something obvious, I am relatively new to Elixir and Phoenix.
I am wondering if there isn official way of handling errors, e.g. cancelling failed uploads.
I am following the example in the official guide: External Uploads — Phoenix LiveView v0.15.4
From what I can gather, there is a list of entries for the uploading files @uploads.file.entries
, and a list of errors @uploads.file.errors
that is populated when an error occurs, but there isn’t really a connection between the two apart from them sharing the “ref”.
I’m finding that I have to do something like this:
<%= for entry <- @uploads.file.entries do %>
<%= entry.client_name %> - <%= entry.progress %>%
<%= if @uploads.file.errors |> Enum.into(%{}) |> Map.has_key?(entry.ref) do %>
<span phx-click="clear-failed-upload" phx-value-ref="<%= entry.ref %>">Clear</span>
<% end %>
<% end %>
I’m rather new to Phoenix, so I don’t really have a frame of reference to know if this is a typical pattern, but my initial reaction is that this seems a bit contrived for what I would image is a common use case.
Would anyone be able to shed some light on this?
Thanks