Repository is archived
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Ftp storage support for paperclip file attachment
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

PaperclipFTP¶ ↑

Ftp storage support for paperclip file attachment plugin. Useful for CDNs with ftp access method for file uploading.

Install¶ ↑

gem install paperclipftp

Usage¶ ↑

In your model:

class User < ActiveRecord::Base
  has_attached_file :avatar,
                    :styles => { :medium => "300x300>", :thumb => "100x100>" },
                    :path => "/path-to-images/:attachment/:id/:style/:filename",
                    :url => "http://my-cdn-domain.com/:attachment/:id/:style/:filename",
                    :storage => :ftp,
                    :ftp_credentials => Rails.root.join('config', 'paperclipftp.yaml')
end

or

class User < ActiveRecord::Base
  has_attached_file :avatar,
                    :styles => { :medium => "300x300>", :thumb => "100x100>" },
                    :path => "/path-to-images/:attachment/:id/:style/:filename",
                    :url => "http://my-cdn-domain.com/:attachment/:id/:style/:filename",
                    :storage => :ftp,
                    :ftp_credentials => { :host => 'ftp.domain.com', :username => 'username', :password => 'password' },
                    :ftp_passive_mode => false,
                    :ftp_timeout => 90,
                    :ftp_verify_size_on_upload => false,
                    :ftp_debug_mode => false
end

Options storage, ftp_credentials, path and url are mandatory.

  • storage: Should be set to ‘ftp’ value in order to utilize paperclipftp plugin

  • ftp_credentials: Takes a path, a File, or a Hash. The path (or File) must point to a YAML file containing the host, username, and password to ftp server. You can ‘environment-space’ this just like you do to your database.yml file, so different environments can use different accounts:

    development:
      host: domain.com
      username: user
      password: password
    test:
      ...
    production:
      ...

    This is not required, however, and the file may simply look like this:

    host: domain.com
    username: user
    password: password

    In which case, those values will be used in all environments.

  • path: This is the templated path to the directory on the ftp server in which the file will be stored.

  • url: This is the templated url to the files as accessed from CDN.

Other options are optional.

  • ftp_passive_mode: True if ftp communication should happen in passive mode

  • ftp_timeout: Max amount of time in seconds to allocate to ftp operations of the plugin

  • ftp_debug_mode: If true, dumps copy of all ftp commands to stderr

  • ftp_verify_size_on_upload: If true, file size will be verified after each upload

Copyright © 2010 Damian Caruso. See LICENSE for details.