Class: CarrierWave::Storage::AWS

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clear_connection_cache!Object



10
11
12
# File 'lib/carrierwave/storage/aws.rb', line 10

def self.clear_connection_cache!
  @connection_cache = {}
end

.connection_cacheObject



6
7
8
# File 'lib/carrierwave/storage/aws.rb', line 6

def self.connection_cache
  @connection_cache ||= {}
end

Instance Method Details

#connectionObject



24
25
26
27
28
# File 'lib/carrierwave/storage/aws.rb', line 24

def connection
  @connection ||= begin
    self.class.connection_cache[credentials] ||= ::AWS::S3.new(*credentials)
  end
end

#credentialsObject



30
31
32
# File 'lib/carrierwave/storage/aws.rb', line 30

def credentials
  [uploader.aws_credentials].compact
end

#retrieve!(identifier) ⇒ Object



20
21
22
# File 'lib/carrierwave/storage/aws.rb', line 20

def retrieve!(identifier)
  AWSFile.new(uploader, connection, uploader.store_path(identifier))
end

#store!(file) ⇒ Object



14
15
16
17
18
# File 'lib/carrierwave/storage/aws.rb', line 14

def store!(file)
  AWSFile.new(uploader, connection, uploader.store_path).tap do |aws_file|
    aws_file.store(file)
  end
end