0

我有一个 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'
.....
4

2 回答 2

0

损坏的正则表达式看起来像在这里检查

因为这段你的代码

format, width, height, depth全部设置为nil因为由于损坏而scan返回nilregex

regex我建议从您这边修复,直到他们修复并修补它

希望这有帮助

于 2013-05-06T09:46:32.283 回答
0

我在使用 rake 任务根据 excel 文档中的列导入图像时遇到了这个错误。我花了几分钟才意识到,如果文件名字段为空白,这将是由此产生的错误。

我希望对某人有所帮助:)

于 2014-01-23T04:45:31.700 回答