附件得到验证错误 - attachment getting validation error

- 此内容更新于:2016-02-01
主题:

所以我有一个应用程序,用户可以上传视频和。超薄技术说明文件。我的问题是,我得到以下错误消息,当试图上传。vtt文件:这是我的验证的领域,我已经包括了“文本/vtt”格式,是什么问题?

原文:

So I have an application where users can upload videos and .vtt caption files.

The issue I'm having is that I get the following error messages when attempting to upload a .vtt file:

Caption has an extension that does not match its contents
Caption is invalid
Caption content type is invalid

Here is my validation for the field, I've included 'text/vtt' format, what is the issue?

  validates_attachment_content_type :caption, :content_type => ['application/txt', 'text/plain', 'text/vtt']
网友:你能把之前的线喜欢…吗?和告诉我它打印

(原文:Can you put the line before .save like puts attachment_content_type..? and tell me what it prints)

网友:Arup说过,您需要确定文件类型实际上是什么,很模糊

(原文:As Arup said, you need to determine what the file type actually is; it's quite obscure)

楼主:谢谢Arup,我添加使attachment_content_type哪里?没有。保存在模型中

(原文:Thanks Arup, where do I add puts attachment_content_type? there's no .save in the model)