Method: CloudCrowd::AssetStore::S3Store#setup

Defined in:
lib/cloud_crowd/asset_store/s3_store.rb

#setupObject

Configure authentication and establish a connection to S3, first thing.



11
12
13
14
15
16
17
18
19
# File 'lib/cloud_crowd/asset_store/s3_store.rb', line 11

def setup
  @use_auth   = CloudCrowd.config[:s3_authentication]
  bucket_name = CloudCrowd.config[:s3_bucket]
  key, secret = CloudCrowd.config[:aws_access_key], CloudCrowd.config[:aws_secret_key]
  valid_conf  = [bucket_name, key, secret].all? {|s| s.is_a? String }
  raise Error::MissingConfiguration, "An S3 account must be configured in 'config.yml' before 's3' storage can be used" unless valid_conf
  @s3         = ::AWS::S3.new(:access_key_id => key, :secret_access_key => secret, :secure => !!@use_auth)
  @bucket     = (@s3.buckets[bucket_name].exists? ? @s3.buckets[bucket_name] : @s3.buckets.create(bucket_name))
end