dalecaru / paperclipftp Goto Github PK
View Code? Open in Web Editor NEWFtp storage support for paperclip file attachment
License: MIT License
Ftp storage support for paperclip file attachment
License: MIT License
I have the following model (with omitted sensitive info):
class Asset < ActiveRecord::Base
has_attached_file :file,
:styles => { :thumb => ["100x100>", ".png"] },
:path => "/app/#{ Rails.env}/:attachment/:id/:style/:filename",
:url => "http://***.com/~*user*/app/#{ Rails.env}/:attachment/:id/:style/:filename",
:storage => :ftp,
:ftp_credentials => Rails.root.join('config', 'paperclipftp.yaml')
validates_attachment_presence :file
delegate :url, to: :file
end
File uploads work fine and images get thumbnails properly.
At first I didn't specify that thumbs should be saved as .png, so when I tried uploading a pdf the thumb didn't display correctly. So I added the ".png" setting, which fixes it for new uploads. I then tried to run the rake task:
$ rake paperclip:refresh:thumbnails CLASS=Asset
rake aborted!
No such file or directory - //app/development/files/2/original/tr11_03.pdf20120217-4756-auwcka.lock
Tasks: TOP => paperclip:refresh:thumbnails
(See full trace by running task with --trace)
So it looks like it tries to access the file locally. Same thing happens when I do it from the Rails console. This isn't critical for me since the error happened in my dev environment and new uploads aren't affected, but I thought I'd report my findings.
I get this error when I tried to upload a file in Active Admin.
I'm using ruby 1.9.3, Rails 3.2.5 and paperclip 3.0.4.
My model:
class FinanceData < ActiveRecord::Base
attr_accessible :title, :data, :data_file_name, :data_content_type, :data_file_size, :data_updated_at
has_attached_file :data,
:path => "/public_html/testes/finance_data/:id/:style/:basename.:extension",
:url => "http://www.domain.com/testes/finance_data/:id/:style/:basename.:extension",
:storage => :ftp,
:ftp_credentials => Rails.root.join('config', 'paperclipftp.yaml')
end
i see that it somehow related to folder structure:
Rendered C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/r
escues/_trace.erb (0.0ms)
Rendered C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/r
escues/_request_and_response.erb (15.5ms)
Rendered C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/r
escues/diagnostics.erb within rescues/layout (77.7ms)
PaperclipFTP: Creating ftp connection
put: TYPE I
get: 200 Type set to I.
put: SIZE /D:/Sites/paper/publichttp://my-cdn-domain.com/photos/1/original/Copy (2) of Copy of Copy of Copy of Water lil
ies.jpg
get: 550 The parameter is incorrect.
put: TYPE I
get: 200 Type set to I.
put: SIZE /D:/Sites/paper/publichttp://my-cdn-domain.com/photos/1/medium/Copy (2) of Copy of Copy of Copy of Water lilie
s.jpg
get: 550 The parameter is incorrect.
put: TYPE I
get: 200 Type set to I.
put: SIZE /D:/Sites/paper/publichttp://my-cdn-domain.com/photos/1/large/Copy (2) of Copy of Copy of Copy of Water lilies
.jpg
get: 550 The parameter is incorrect.
put: TYPE I
get: 200 Type set to I.
put: SIZE /D:/Sites/paper/publichttp://my-cdn-domain.com/photos/1/thumb/Copy (2) of Copy of Copy of Copy of Water lilies
.jpg
get: 550 The parameter is incorrect.
put: TYPE I
get: 200 Type set to I.
put: SIZE /D:/Sites/paper/publichttp://my-cdn-domain.com/photos/1/small/Copy (2) of Copy of Copy of Copy of Water lilies
.jpg
get: 550 The parameter is incorrect.
PaperclipFTP: Closing ftp connection
PaperclipFTP: Creating ftp connection
put: TYPE I
get: 200 Type set to I.
put: PORT 10,125,51,52,9,55
get: 200 PORT command successful.
put: STOR /D:/Sites/paper/publichttp://my-cdn-domain.com/photos/1/medium/Copy (3) of Copy of Copy of Blue hills.jpg
get: 550 The parameter is incorrect.
put: CWD /
get: 250 CWD command successful.
put: CWD D:
get: 550 The parameter is incorrect.
put: MKD D:
get: 550 The parameter is incorrect.
PaperclipFTP: Closing ftp connection
I'm getting this error:
`@[]' is not allowed as an instance variable name
when using paperclipftp with Rails 3.1
create a new file as config/environment.rb and add this code:
Rails::Initializer.run do |config|
...
config.after_initialize do
if Rails.env == 'development'
Paperclip::Attachment.default_options.merge!(:storage => :ftp)
end
end
end
I'm using paperclipftp to store attachment on ftp server. When I use delayed_job to postpone image processing, it won't work, when paperclip tries to reprocess remotely stored image.
It works ok when reprocesses locally stored images so I think that there's might be some problem with that how it handles remote images.
paperclipftp works perfectly when developing in ruby 1.8.7 but if i switch to 1.9.2 using rvm in mac os x i get this error when i start the webbrick server using the 'rails s' command:
/Users/phaser/Sites/porlaputa/vendor/ruby/1.9.1/gems/paperclipftp-0.2.4/lib/paperclipftp.rb:4:in `<module:Ftp>': uninitialized constant Paperclip::Storage::Ftp::Timeout (NameError)
from /Users/phaser/Sites/porlaputa/vendor/ruby/1.9.1/gems/paperclipftp-0.2.4/lib/paperclipftp.rb:3:in `<module:Storage>'
from /Users/phaser/Sites/porlaputa/vendor/ruby/1.9.1/gems/paperclipftp-0.2.4/lib/paperclipftp.rb:2:in `<module:Paperclip>'
from /Users/phaser/Sites/porlaputa/vendor/ruby/1.9.1/gems/paperclipftp-0.2.4/lib/paperclipftp.rb:1:in `<top (required)>'
from /Users/phaser/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
from /Users/phaser/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/phaser/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
from /Users/phaser/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
from /Users/phaser/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
from /Users/phaser/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
from /Users/phaser/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
from /Users/phaser/Sites/porlaputa/config/application.rb:7:in `<top (required)>'
from /Users/phaser/Sites/porlaputa/vendor/ruby/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `require'
from /Users/phaser/Sites/porlaputa/vendor/ruby/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/phaser/Sites/porlaputa/vendor/ruby/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /Users/phaser/Sites/porlaputa/vendor/ruby/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
i´ve googled the hell out of this problem and it seems im the only one. perhaps there is an incompatibility with the gems in my application? my Gemfile is this:
source 'http://rubygems.org'
gem 'rails', '3.0.9'
gem "rake", "0.8.7"
gem 'sqlite3'
gem 'authlogic'
gem 'cancan'
gem 'paperclip'
gem 'paperclipftp'
gem 'twitter'
gem 'hoptoad_notifier'
gem 'heroku'
gem 'kaminari'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.