我在Rails 4上,我正在使用Paperclip进行文件上传。我正在拼命尝试构建一个功能,允许用户上传PDF并生成第一页的图像预览(拇指)。
以下代码不起作用。
has_attached_file :main_file, :styles => { :thumb => ["140x140>", :jpg] }
validates_attachment_content_type :main_file, content_type: [
'application/pdf','image/jpg'], :message => "This file type isn\'t supported."
我收到错误:
Command :: file -b --mime '/var/folders/k_/wsf8hnls5lv244dgc982p7z80000gn/T/fab3d5a75486d28281706cf858adadb120151026-57461-ajikva.pdf'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/k_/wsf8hnls5lv244dgc982p7z80000gn/T/e82c7d6f66ad28d20a7f16bd98f714d620151026-57461-qtre7l.pdf[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
Command :: file -b --mime '/var/folders/k_/wsf8hnls5lv244dgc982p7z80000gn/T/fab3d5a75486d28281706cf858adadb120151026-57461-1p3ud7o.pdf'
(0.2ms) rollback transaction
(0.1ms) begin transaction
Command :: file -b --mime '/var/folders/k_/wsf8hnls5lv244dgc982p7z80000gn/T/fab3d5a75486d28281706cf858adadb120151026-57461-5ufnwc.pdf'
(0.2ms) rollback transaction