CloudFiles storage for Paperclip
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.document
.gitignore
LICENSE
README.rdoc
Rakefile
VERSION
paperclip_cloudfiles.gemspec

README.rdoc

paperclip_cloudfiles

Enables CloudFiles storage for Paperclip. Also provides a simple mechanism for defining default settings for Paperclip attachments. Be warned that this project is largely untested. It has worked for me in a limited number of specific cases, but as experience shows, this is no guarantee of general soundness. You've been warned.

Installation

sudo gem install erikhansson-paperclip_cloudfiles

Setup

environment.rb

config.gem 'erikhansson-paperclip_cloudfiles', :lib => 'paperclip_cloudfiles', :source => 'http://gems.github.com'

production.rb (or some other source of configuration)

Paperclip::WithDefault.use_cloudfiles_options :cloudfiles => {
  :credentials => {
      :username => 'username',
      :api_key => 'abcdefghijklmnopqrstuvxyz1234567'
    },
  :container => 'container_name',
  :base_url => 'http://xxxxyyyy.cdn.cloudfiles.rackspacecloud.com'
}

Usage

class Model < ActiveRecord::Base

  has_attached_file_with_defaults :image, :styles => { :display => "675>" }

end

What's going on?

has_attached_file_with_defaults simply calls the familiar Paperclip has_attached_file method with a set of default options, found in Paperclip::WithDefault.options.

Paperclip::WithDefault.use_cloudfiles_options, sets this default options hash to some convenient default settings for CloudFiles. You can also set it directly using Paperclip::WithDefault.options=

You can also set different default settings for the test and development environments. In fact, the test environment automagically gets new default settings { :url => '/system_test/:attachment/:id/:style/:filename' } to keep files uploaded during tests to comingle with actual uploaded files.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2009 Erik Hansson. See LICENSE for details.