Class: CarrierWave::Storage::CloudFiles

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

Overview

Uploads things to Rackspace Cloud Files webservices using the Rackspace libraries (cloudfiles gem). In order for CarrierWave to connect to Cloud Files, you’ll need to specify an username, api key and container. Optional arguments are config.cloud_files_snet (using the private internal Rackspace network for communication) and config.cloud_files_auth_url (for connecting to Rackspace’s UK infrastructure or an OpenStack Swift installation)

CarrierWave.configure do |config|
  config.cloud_files_username = "xxxxxx"
  config.cloud_files_api_key = "xxxxxx"
  config.cloud_files_container = "my_container"
  config.cloud_files_auth_url = "https://lon.auth.api.rackspacecloud.com/v1.0"
  config.cloud_files_snet = true
end

You can optionally include your CDN host name in the configuration. This is highly recommended, as without it every request requires a lookup of this information.

config.cloud_files_cdn_host = "c000000.cdn.rackspacecloud.com"

Defined Under Namespace

Classes: File

Instance Attribute Summary

Attributes inherited from Abstract

#uploader

Instance Method Summary collapse

Methods inherited from Abstract

#identifier, #initialize

Constructor Details

This class inherits a constructor from CarrierWave::Storage::Abstract

Instance Method Details

#retrieve!(identifier) ⇒ Object

Do something to retrieve the file

identifier (String)

uniquely identifies the file

Returns

CarrierWave::Storage::CloudFiles::File

the stored file

Parameters:

  • identifier (String)

    uniquely identifies the file



181
182
183
# File 'lib/carrierwave/storage/cloud_files.rb', line 181

def retrieve!(identifier)
  CarrierWave::Storage::CloudFiles::File.new(uploader, self, uploader.store_path(identifier))
end

#store!(file) ⇒ Object

Store the file on Cloud Files

Parameters

file (CarrierWave::SanitizedFile)

the file to store

Returns

CarrierWave::Storage::CloudFiles::File

the stored file



164
165
166
167
168
169
# File 'lib/carrierwave/storage/cloud_files.rb', line 164

def store!(file)
  cloud_files_options = {'Content-Type' => file.content_type}
  f = CarrierWave::Storage::CloudFiles::File.new(uploader, self, uploader.store_path)
  f.store(file.read,cloud_files_options)
  f
end