6

I'd like to allow my application to permit .vtt files on upload. Right now it was only accepting .txt files, but I'd like to add .vtt capability for captions.

I've tried this *with no luck:

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

What is the proper format in this case?

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
Sonny Black
  • 1,585
  • 4
  • 23
  • 41
  • 1
    The MIME type for WebVTT is `text/vtt`: https://w3c.github.io/webvtt/#webvtt-file – Jordan Running Jan 18 '16 at 20:03
  • didn't work. any ideas? – Sonny Black Jan 31 '16 at 21:48
  • 1
    WebVTT is a very new standard, and so a very new MIME type. Rails might not know about it yet. You may have to just check the extension or come up with your own validation by checking the actual data [against the spec](https://w3c.github.io/webvtt/#webvtt-file-body). – Jordan Running Jan 31 '16 at 21:58

1 Answers1

11

The MIME type for WebVTT caption files is text/vtt as specified in https://w3c.github.io/webvtt/#iana-text-vtt

Aleksandr Dubinsky
  • 22,436
  • 15
  • 82
  • 99
Peter
  • 573
  • 3
  • 12