6

I'm trying to find documentations on how to setup Paperclip to use fog.io and fog.io to use Rackspace Cloud File, but I wasn't able to find any good reference (and I consider myself a good Google language speaker :D). The ideal scenario would be a setup where I could use local storage for a development environment and Rackspace for production.

Could anyone point to a good doc or use this space to document this approach?

Tks!

== Update ==:

Paperclip to fog.io

https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/storage/fog.rb

fog.io to Rackspace Cloud File

http://fog.io/storage/

... still trying to figure out how to put these together.

Shadoath
  • 720
  • 1
  • 15
  • 31
David Lojudice Sb.
  • 1,302
  • 1
  • 15
  • 26

1 Answers1

11

I think I got it.

On config/initializers/paperclip_defaults.rb

Paperclip::Attachment.default_options.update({
  :path => "images/:class/:id/:attachment/:style/img_:fingerprint",
  :storage => :fog,
  :fog_credentials => {
    :provider           => 'Rackspace',
    :rackspace_username => 'blablabla',
    :rackspace_api_key  => 'blablabla',
    :persistent => false
  },
  :fog_directory => 'blablabla',
  :fog_public => true,
  :fog_host => 'http://blablabla.rackcdn.com'
})

where...

:fog_directory - This is your Rackspace Cloud File container.

:fog_host - The Cloud File CDN URL

:persistent - To prevent a bug on Fog/Excon. You may not need this on the future.

Also use :fingerprint paperclip feature to avoid CDN cache when you update the file.

David Lojudice Sb.
  • 1,302
  • 1
  • 15
  • 26
  • 2
    Worked great. I did not need to include fog_host. – Kyle Heironimus Apr 12 '12 at 19:59
  • I am using the same paperclip_defaults.rb settings you mentioned above. I have added gem 'fog' to my gemfile. but when I do require 'fog' on console, it return False. I actually am trying to read the file I just uploaded to Rackspace on rails console. Any help appreciated – Ketan Deshmukh Jun 04 '13 at 10:08
  • Ketan: Bundler already attempts to require fog when it loads. If it loads successfully and you try to load it again, the require command will return false. – eltiare Nov 05 '13 at 19:39