Skip to content
Riak support for CarrierWave
Latest commit f9b1caa Jul 30, 2014 @motske Bumped version
Failed to load latest commit information.
lib/carrierwave Bumped version Jul 30, 2014
Gemfile Updated Gemfile to use gemspec Mar 14, 2013
Rakefile Added bundler gem tasks Nov 13, 2012
carrierwave-riak.gemspec relax riak-client version requirement Mar 14, 2013

CarrierWave for Riak

This gem adds storage support for Riak to CarrierWave

This module should work for basic uploads, but hasn't been tested with all features of carrierrwave and is very new. The code was initially based on carrierwave-upyun but also uses ideas taken from the built in Fog storage provider.


gem install carrierwave-riak

Or using Bundler, in Gemfile

gem 'riak-client'
gem 'carrierwave-riak', :require => "carrierwave/riak"


You'll need to configure the Riak client in config/initializers/carrierwave.rb

CarrierWave.configure do |config| = :riak
  config.riak_host = 'localhost'
  config.riak_port = 8098

or, if you use claster of nodes

CarrierWave.configure do |config| = :riak
  config.riak_nodes = [
    { host: "", http_port: 8098 }, 
    { host: "", http_port: 8099 }

Usage example

Note that for your uploader, your should extend the CarrierWave::Uploader::Riak class.

class DocumentUploader < CarrierWave::Uploader::Riak

    # If key method is not defined, Riak generated keys will be used and returned as the identifier

    def key

    def bucket

Using Riak generated keys

Because the orm record is saved before the storage object is, the orm record needs to be updated after saving to storage if a Riak generated key is to be used as the identifier. The CarrierWave::Uploader::Riak class defines an :after callback to facilitate this. This only works for ActiveRecord and is likely pretty hacky. Maybe someone can suggest a better way to deal with this.


  • Write specs. Bad programmer.


If this is helpful to you, but isn't quite working please send me pull requests.

Something went wrong with that request. Please try again.