参考了这篇教程:https://devcenter.heroku.com/articles/paperclip-s3。但是我现在正在本地测试,所以我安装了Figaro gem并将我的S3信息放在application.yml中。
使用Rails v4、Cocaine v0.5.3和Paperclip v4.1.0(不确定是否需要提及其他gem版本号)。
我有一个名为SubmissionDetails的模型,在它的new.html.erb中,我试图上传一个jpg到名为attachment的列中。以下是相关的模型代码:
has_attached_file :attachment, styles: {
thumb: '200x200>',
large: '800x800>'
}
validates_attachment_content_type :attachment, content_type: /\Aimage\/.*\Z/
当我尝试上传JPG文件时,它会返回到表单,并显示以下错误消息:
1 error prohibited this submission_detail from being saved:
Attachment translation missing:
en.activerecord.errors.models.submission_detail.attributes.attachment.spoofed_media_type
我已经理解了一部分错误,即我的en.yml文件中缺少显示此错误消息的文本,但关于伪造的媒体类型部分呢?
这出现在我的服务器控制台中,不确定是否相关:
[paperclip] Content Type Spoof: Filename header.jpg (["image/jpeg"]), content type discovered from file command: . See documentation to allow this combination.
(0.0ms) rollback transaction
file
命令确定真实的文件类型。你尝试过不同的文件类型(png,gif)了吗? - pdu