xing/paperclip-storage-ftp

No such file or directory

Closed this issue · 4 comments

Hello,

firstly, thanks for this really useful gem!

However, I run into issues when trying to save attachment. I get:

450 /zines/2/original: No such file or directory

Backtrace:

/home/vidmantas/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/ftp.rb:324:in `getresp'
/home/vidmantas/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/ftp.rb:338:in `voidresp'
/home/vidmantas/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/ftp.rb:526:in `block (2 levels) in retrlines'
/home/vidmantas/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/ftp.rb:199:in `with_binary'
/home/vidmantas/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/ftp.rb:512:in `block in retrlines'
/home/vidmantas/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/home/vidmantas/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/ftp.rb:511:in `retrlines'
/home/vidmantas/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/ftp.rb:744:in `nlst'
paperclip-storage-ftp (1.0.3) lib/paperclip/storage/ftp/server.rb:26:in `file_exists?'
paperclip-storage-ftp (1.0.3) lib/paperclip/storage/ftp.rb:12:in `exists?'
paperclip (3.4.1) lib/paperclip/attachment.rb:458:in `block in queue_all_for_delete'
paperclip (3.4.1) lib/paperclip/attachment.rb:457:in `map'
paperclip (3.4.1) lib/paperclip/attachment.rb:457:in `queue_all_for_delete'
paperclip (3.4.1) lib/paperclip/attachment.rb:226:in `clear'
paperclip (3.4.1) lib/paperclip/attachment.rb:95:in `assign'
paperclip (3.4.1) lib/paperclip.rb:200:in `block in has_attached_file'

Of course that this subdirectory in FTP does not exists yet, because it's a new file... What I'm missing here? I don't believe this gem doesn't support folder creation on new attachment upload, but I don't see what's wrong.

My paperclip setup:

has_attached_file :zine_logo, 
  :storage => :ftp,
  :styles => { :small => "200x500>" },
  :path => '/zines/:id/:style/:filename',
  :url  => 'http://myurl.com/zines/:id/:style/:filename',
  :ftp_servers => [
    { 
      :host     => FTP_HOST,
      :user     => FTP_USER,
      :password => FTP_PASS,
      :passive  => true
    }
  ]

It seems the ftp server you are using does not like the NLST command being run on a non-existing directory.

I prepared a branch that rescues the exception: cdea1a4.

Please try it out by changing your Gemfile and let me know if it fixes your problem:

gem 'paperclip-storage-ftp', :git => 'git://github.com/xing/paperclip-storage-ftp.git', :branch => 'handle-450'

Yes, when using this branch it works perfectly!

Are you going to release updated version soon or I should use this branch instead?

Thanks for the feedback!

I released a new gem version to include the fix: 1.0.4.

Perfect! Thanks, Sebastian!