Question

I've a rake task for importing pdf's from my filesystem into GridFS via dragonfly-gem. The task fails with no obvious reason. I appreciate any help. Thanks!

The rake task:

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

Stacktrace:

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'
....

I've double checked the folder "safety". There are just pdf files in it (mime-tpye checked with file -i *). I think the issue is related to dragonfly, because when imagemagick is avtivated in the dragonfly config..

app.configure_with(:imagemagick)

the stacktrace is different:

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'
.....
Was it helpful?

Solution

Broken regex look like check here

because of which this piece of ur code

i.e format, width, height, depth all are set to nil because scan is returning nil because of broken regex

fix the regex from your side is what I suggest until they fix it and patch it

Hope this help

OTHER TIPS

I ran into this error while using a rake task to import images based on a column in an excel document. Took me a few minutes to realize that if the file name field was blank this would be the resulting error.

I hope that helps someone :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top