【问题标题】:What is the content_type for WebVtt?WebVtt 的 content_type 是什么?
【发布时间】:2016-01-18 19:36:14
【问题描述】:

我想允许我的应用程序在上传时允许 .vtt 文件。目前它只接受 .txt 文件,但我想为字幕添加 .vtt 功能。

我试过这个*没有运气:

validates_attachment_content_type :caption, 
  :content_type => ['application/txt', 'text/plain', 'WEBVTT', 'application/vtt', 'vtt']

在这种情况下,正确的格式是什么?

【问题讨论】:

  • WebVTT 的 MIME 类型是 text/vtt: w3c.github.io/webvtt/#webvtt-file
  • 没用。有什么想法吗?
  • WebVTT 是一个非常新的标准,因此是一个非常新的 MIME 类型。 Rails 可能还不知道。您可能只需要检查扩展名或通过检查实际数据 against the spec 来进行自己的验证。

标签: ruby-on-rails ruby paperclip content-type webvtt


【解决方案1】:

WebVTT 字幕文件的 MIME 类型为 text/vtt,在 https://w3c.github.io/webvtt/#iana-text-vtt 中指定

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-28
    • 1970-01-01
    • 2021-10-01
    • 2018-10-18
    • 2014-03-07
    相关资源
    最近更新 更多