Class: CarrierWave::Storage::Couch

Inherits:
Abstract
  • Object
show all
Defined in:
lib/carrierwave/storage/couch.rb

Overview

Couch storage stores file to the Couchdb (surprising, no?). There’s really not much to it.

Creating a connection looks something like this:

  CarrierWave.configure do |config|
    config.storage = :couch
    config.couch_host = "your-host.com"
    config.couch_port = "5984"
    config.couch_database = "your_dbs_app_name"
    config.couch_username = "user"
    config.couch_password = "verysecret"
    config.couch_access_url = "/images"
  end

In the above example your documents url will look like:

   http://your-app.com:5984/:database/:document_id/:document-identifier-here

When you already have a CouchDB connection object :

CarrierWave.configure do |config|
  config.storage = :couchdb
  config.couch_connection = model.use_database
  config.couch_access_url = "/images"
end

Defined Under Namespace

Classes: File

Instance Method Summary collapse

Instance Method Details

#retrieve!(identifier) ⇒ Object

Retrieve the file from its store path

Parameters

identifier (String)

the filename of the file

Returns

CarrierWave::Storage::Couch::File

a couch file



143
144
145
# File 'lib/carrierwave/storage/couch.rb', line 143

def retrieve!(identifier)
  CarrierWave::Storage::Couch::File.new(uploader, identifier)
end

#store!(file) ⇒ Object

Move the file to the uploader’s store path.

Parameters

file (CarrierWave::Storage::Couch::File)

the file to store

Returns

CarrierWave::Storage::Couch::File

a couch file



126
127
128
129
130
# File 'lib/carrierwave/storage/couch.rb', line 126

def store!(file)
  f = CarrierWave::Storage::Couch::File.new(uploader, '')
  f.store(file)
  f
end