0
我正在使用rails 3 + paperclip + s3(专用存储桶)来允许用户上传文件。回形针无法为无扩展名的文件设置attachment_content_type
用户可以上传没有扩展名的文件,例如rails gemfile,它只是“gemfile”而不是“gemfile.txt”当您上传此文件时,paperclip不会设置attachment_content_type。
我确定CONTENT_TYPE像这样:
self.attachment.instance_write(:content_type, MIME::Types.type_for(self.attachment_file_name).to_s)
有没有更好的办法做到这一点,更可靠,解决了上述的错误?谢谢
你能接受的答案@RachelDRoy? – MrYoshiji