How to display upload_errors in a flash message?

Okay, so maybe I am a little tired, but I can’t figure this out right now. The solution probably is simple :smiley:

Is there any way to show the errors retrieved from upload_errors/2 when using LiveView Uploads in a flash message?

The link I am missing right now is, where can I call put_flash when an upload got errors?

Nevermind. The obvious solution is to extract the errors in the validation event and call put_flash there. :man_facepalming:

def handle_event("validate_upload", params, socket) do
    errors =
      for entry <- socket.assigns.uploads.editor_images.entries,
          err <- upload_errors(socket.assigns.uploads.editor_images, entry),
          do: error_to_string(err)

    socket = put_flash(socket, :error, Enum.join(errors, ", "))
    
    {:noreply, socket}
  end