Class: CloudCrowd::AssetStore

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud_crowd/asset_store.rb,
lib/cloud_crowd/asset_store/s3_store.rb,
lib/cloud_crowd/asset_store/cloudfiles_store.rb,
lib/cloud_crowd/asset_store/filesystem_store.rb

Overview

The AssetStore provides a common API for storing files and returning URLs that can access them. At the moment, the files can be saved to either S3, or the local filesystem. You shouldn’t need to use the AssetStore directly – Action’s download and save methods use it behind the scenes.

To implement a new back-end for the AssetStore, you must provide save(local_path, save_path), cleanup(job), and optionally, a setup method that will be called once at initialization.

Defined Under Namespace

Modules: CloudfilesStore, FilesystemStore, S3Store

Instance Method Summary collapse

Constructor Details

#initializeAssetStore

Creating the AssetStore ensures that its scratch directory exists.



29
30
31
32
33
# File 'lib/cloud_crowd/asset_store.rb', line 29

def initialize
  FileUtils.mkdir_p temp_storage_path unless File.exists? temp_storage_path
  raise Error::StorageNotWritable, "#{temp_storage_path} is not writable" unless File.writable?(temp_storage_path)
  setup if respond_to? :setup
end

Instance Method Details

#temp_storage_pathObject

Get the path to CloudCrowd’s temporary local storage. All actions run in subdirectories of this.



37
38
39
# File 'lib/cloud_crowd/asset_store.rb', line 37

def temp_storage_path
  @temp_storage_path ||= CloudCrowd.config[:temp_storage_path] ||  "#{Dir.tmpdir}/cloud_crowd_tmp"
end