我有一个 rake 任务,通过 Dragonfly-gem 将 pdf 从我的文件系统导入到 GridFS。任务失败,没有明显的原因。我很感激任何帮助。谢谢!
耙子任务:
task :worksafety_files => :environment do
# Importiert Archiv-Dateien via Dragonfly in GridFS
Worksafety.all.each do |worksafety|
if worksafety.doc_1_tmp != nil and File.exist?("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_1_tmp}")
worksafety.doc_1 = File.new("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_1_tmp}")
worksafety.doc_1_tmp = nil
end
if worksafety.doc_2_tmp != nil and File.exist?("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_2_tmp}")
worksafety.doc_2 = File.new("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_2_tmp}")
worksafety.doc_2_tmp = nil
end
if worksafety.doc_3_tmp != nil and File.exist?("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_3_tmp}")
worksafety.doc_3 = File.new("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_3_tmp}")
worksafety.doc_3_tmp = nil
end
if File.exist?("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_4_tmp}")
worksafety.doc_4 = File.new("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_4_tmp}")
worksafety.doc_4_tmp = nil
end
if File.exist?("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_5_tmp}")
worksafety.doc_5 = File.new("#{Rails.root}/config/mongify/archiv/safety/#{worksafety.doc_5_tmp}")
worksafety.doc_5_tmp = nil
end
worksafety.save
end
end
堆栈跟踪:
rake aborted!
Is a directory - read
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly-08de999d19a0/lib/dragonfly/temp_object.rb:198:in `copy_to_tempfile'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly-08de999d19a0/lib/dragonfly/temp_object.rb:100:in `tempfile'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly-08de999d19a0/lib/dragonfly/temp_object.rb:107:in `file'
....
我已经仔细检查了文件夹“安全”。里面只有pdf文件(mime-tpye用文件-i *检查)。我认为这个问题与蜻蜓有关,因为当 imagemagick 在蜻蜓配置中被激活时..
app.configure_with(:imagemagick)
堆栈跟踪不同:
rake aborted!
undefined method `downcase' for nil:NilClass
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly- 08de999d19a0/lib/dragonfly/image_magick/utils.rb:26:in `identify'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly-08de999d19a0/lib/dragonfly/image_magick/analyser.rb:44:in `format'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly-08de999d19a0/lib/dragonfly/function_manager.rb:39:in `call'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly-08de999d19a0/lib/dragonfly/function_manager.rb:39:in `block (2 levels) in call_last'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly-08de999d19a0/lib/dragonfly/function_manager.rb:38:in `catch'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly-08de999d19a0/lib/dragonfly/function_manager.rb:38:in `block in call_last'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bundler/gems/dragonfly-08de999d19a0/lib/dragonfly/function_manager.rb:37:in `each'
.....