GithubHelp home page GithubHelp logo

carrierwave-riak's Introduction

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.

Installation

gem install carrierwave-riak

Or using Bundler, in Gemfile

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

Configuration

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

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

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
        original_filename
    end

    def bucket
      "my_bucket"
    end
end

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.

TODO

  • Write specs. Bad programmer.

Contributing

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

carrierwave-riak's People

Contributors

motske avatar jedl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.