As of 2015-01-22 this is one way of setting up Carrierwave to work with DreamObjects. The dreamobjects docs are woefully out of date useing AWS::S3 gem which fails spectacularly on Rails 4.2 ruby 2.1 (see marcel/aws-s3#98 ).
In the DreamObjects web GUI, if you don't already have a bucket, click "create bucket". Name the bucket. For this example the bucket is named testing-bucket
. Toggle the "private" switch to "public".
For the user enclosing the bucket you just created click on the "keys" button. This will reveal the public key. Click on "show secret key" (to the right of the public key in hardly legible light gray). This will reveal the private key.
Ensure both carrierwave and fog gem are listed in the Gemfile.
gem 'carrierwave'
gem 'fog'
edit config/secrets.yml
(or whatever solution you are using like .env)
Copy the public key from above into "dreamobjects_pub_key".
Copy the private key from above into "dreamobjects_secret_key"
edit config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.fog_credentials = {
provider: "AWS",
aws_access_key_id: Rails.application.secrets.dreamobjects_pub_key,
aws_secret_access_key: Rails.application.secrets.dreamobjects_secret_key,
host: 'objects.dreamhost.com',
# this is the real kicker...
# if you don't do this you'll just keep getting 400 bad request returned
# see https://github.com/fog/fog/issues/3275 for more details
aws_signature_version: 2
}
# bucket name from above...
config.fog_directory = 'testing-bucket'
config.fog_public = true
# include bucket name from above in url...
config.asset_host = 'https://objects.dreamhost.com/testing-bucket'
# this is a heroku thing - you may or may not need to consider this
config.cache_dir = "#{Rails.root}/tmp/uploads"
end
Finally in any of the "uploader" files you create/created with CarrierWave change the "storage" line to read:
storage :fog