livebook-dev / kino

Client-driven interactive widgets for Livebook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kino.Input.file crashes when accepts: is used to provide an unknown MIME type

ntodd opened this issue · comments

Livebook: 0.9.2
Kino: 0.9.4

When attempting to limit the acceptable file types for a Kino.Input.file input, Livebook crashes.

Kino docs say that either MIME type or extension can be used:

:accept - the list of accepted file types (either extensions or MIME types) or :any. Defaults to :any

Code

Kino.Input.file("WebVTT file", accept: ["text/vtt"])

Error

10:56:56.460 [error] #PID<0.15181.0> running LivebookWeb.Endpoint (connection #PID<0.15145.0>, stream id 17) terminated
Server: localhost:59561 (http)
Request: GET /sessions/7xdbk5xzjqtbhz6hqd6uhy3tlpifxforgtcuycjr
** (exit) an exception was raised:
    ** (ArgumentError)   invalid accept filter provided to allow_upload.

  Expected a known MIME type without parameters.

  MIME types can be extended in your application configuration as follows:

  config :mime, :types, %{
    "application/vnd.api+json" => ["json-api"]
  }

  Got:

  "text/vtt"

        (phoenix_live_view 0.18.18) lib/phoenix_live_view/upload_config.ex:411: Phoenix.LiveView.UploadConfig.accept_option!/1
        (phoenix_live_view 0.18.18) lib/phoenix_live_view/upload_config.ex:375: anonymous fn/2 in Phoenix.LiveView.UploadConfig.validate_accept_option/1
        (elixir 1.14.2) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
        (phoenix_live_view 0.18.18) lib/phoenix_live_view/upload_config.ex:374: Phoenix.LiveView.UploadConfig.validate_accept_option/1
        (phoenix_live_view 0.18.18) lib/phoenix_live_view/upload_config.ex:135: Phoenix.LiveView.UploadConfig.build/3
        (phoenix_live_view 0.18.18) lib/phoenix_live_view/upload.ex:28: Phoenix.LiveView.Upload.allow_upload/3
        (livebook 0.9.2) lib/livebook_web/live/output/file_input_component.ex:18: LivebookWeb.Output.FileInputComponent.update/2
        (phoenix_live_view 0.18.18) lib/phoenix_live_view/utils.ex:484: Phoenix.LiveView.Utils.maybe_call_update!/3