回形针,对图像和非图像文件使用相同的字段 archlinux
我使用回形针来存储与模型相关的文件。根据描述,文件可以采用各种格式。我在模型中指定了以下内容:
require 'paperclip'
class Document < ActiveRecord::Base
belongs_to :candidate
attr_accessible :candidate_id, :description, :media
has_attached_file :media, :styles => { :profile => "100x100>" }
validates_attachment_presence :media
validates_attachment_size :media, :less_than => 3.megabytes
end
以前它工作正常。最近,在我对 archlinux 进行了一些系统升级(可能是 Imagemagick 升级)后,我在保存某些格式(例如 .doc .xls 等)时遇到以下错误,但它适用于图像。
* “identify”命令无法识别媒体 /tmp/stream20111020-2130-zeux3k-0.doc。
当我使用文件运行识别命令时,我得到以下信息。
$ identify /tmp/stream20111020-2130-zeux3k-0.doc
identify: no decode delegate for this image format `/tmp/stream20111020-2130-zeux3k-0.doc' @ error/constitute.c/ReadImage/532
Paperclip 是否应该尝试调整 Word 文档的大小?
我能做点什么吗?
I am using paperclip for storing files related to the model. The files can be in various formats depending on the description. I have specified following in the model:
require 'paperclip'
class Document < ActiveRecord::Base
belongs_to :candidate
attr_accessible :candidate_id, :description, :media
has_attached_file :media, :styles => { :profile => "100x100>" }
validates_attachment_presence :media
validates_attachment_size :media, :less_than => 3.megabytes
end
Before sometime it was working fine. Recently after I had some system upgrades of archlinux (may be Imagemagick was upgraded), I have following error while saving certain formats e.g. .doc .xls etc, it works for images though.
* Media /tmp/stream20111020-2130-zeux3k-0.doc is not recognized by the 'identify' command.
When I run identify command with the file I get following.
$ identify /tmp/stream20111020-2130-zeux3k-0.doc
identify: no decode delegate for this image format `/tmp/stream20111020-2130-zeux3k-0.doc' @ error/constitute.c/ReadImage/532
Should Paperclip try to resize the word document at all ?
Anything, I can do about this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我仍然不知道为什么它以前可以工作,但现在不起作用,但我通过向回形针提供条件样式选项找到了解决方法。就像下面...
我仍然想更具体并根据内容类型指定样式
I still don't know why it was working before and now doesn't wok, but I found out a workaround by supplying conditional style options to paperclip. Like following ...
I still want to be more specific and specify style based on the content type