1

I'm writing a Rails 3 app that uses Paperclip to transcode a video file attachment into a bunch of other formats, and then to store the resulting files. It all works fine for local storage, but I am trying to make it work using Paperclip's Fog support to store files in a bucket on our own Ceph cluster. However, I can't seem to find the right configuration options to make Fog talk to my Ceph server.

Here is a snippet from my Rails class:

has_attached_file :videofile,
  :storage => :fog,
  :fog_credentials => { :aws_access_key_id => 'xxx', :aws_secret_access_key => 'xxx', :provider => 'AWS'},
  :fog_public => true,
  :url => ":id/:filename",
  :fog_directory => 'replay',
  :fog_host => 'my-hostname',

Writes using this setup fail because Paperclip attempts to save to Amazon S3 rather than the host I've provided. I have a non-Rails / non-Paperclip toy script working just fine:

conn = Fog::Storage.new({
   :aws_access_key_id => 'xxx',
   :aws_secret_access_key => 'xxx',
   :host => 'my-hostname',
   :path_style => true,
   :provider => "AWS",
})

This correctly connects to my local Ceph server. So I suspect there is something I'm not configuring in Paperclip properly - but what?

Here's the relevant hunk from fog.rb that I think is causing the connection to only go to AWS:

def host_name_for_directory
        if @options[:fog_directory].to_s =~ Fog::AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX
          "#{@options[:fog_directory]}.s3.amazonaws.com"
        else
          "s3.amazonaws.com/#{@options[:fog_directory]}"
        end
      end
4
  • Reading fog.rb, it looks like there are hardcoded assumptions that only AWS S3 is going to be used by the :fog datastore - at least, I think that's what is happening. So I'm evaluating whether it's more sane to patch fog.rb or write a new storage module for Paperclip (or use an alternative, like Dragonfly)
    – mjp
    Jun 20, 2014 at 13:04
  • Either could presumably work. You could perhaps just create a subclass of the existing one that returns what you want for this method (but otherwise delegates to the parent). That should be relatively clean (and hopefully not too prone to breakage).
    – geemus
    Jun 20, 2014 at 18:05
  • Turns out that hunk from fog.rb has little to do with amazon-specificness. I discovered that I can pass the :host inside :fog_credentials, and it gets passed through just fine. However, there's still a Nil class error I'm trying to trace down.
    – mjp
    Jun 23, 2014 at 17:10
  • Glad to hear some progress was made. If you post the nil class error here (or in an issue), I'd be happy to try and help out. Thanks!
    – geemus
    Jun 28, 2014 at 21:26

1 Answer 1

2

the error was just from an improperly configured Ceph cluster. For anyone who finds this thread, as long as you:

  1. Have your wildcard DNS set up properly for your Ceph frontend;
  2. Ceph configured to recognize as such
  3. Pass in :host in :fog_credentials, which would be the FQDN of the Ceph frontend
  4. :fog_host, which apparently needs to be the URL for your bucket, e.g. https://bucket.ceph-server.foobar.com.

Paperclip will work out of the box. I don't think that it is documented anywhere that you can use :host but it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.