Class: CarrierWave::Storage::AWS
- Inherits:
-
Abstract
- Object
- Abstract
- CarrierWave::Storage::AWS
- Defined in:
- lib/carrierwave/storage/aws.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cache!(file) ⇒ Object
- #clean_cache!(_seconds) ⇒ Object
- #connection ⇒ Object
- #credentials ⇒ Object
- #delete_dir!(path) ⇒ Object
- #retrieve!(identifier) ⇒ Object
- #retrieve_from_cache!(identifier) ⇒ Object
- #store!(file) ⇒ Object
Class Method Details
.clear_connection_cache! ⇒ Object
12 13 14 |
# File 'lib/carrierwave/storage/aws.rb', line 12 def self.clear_connection_cache! @connection_cache = {} end |
.connection_cache ⇒ Object
8 9 10 |
# File 'lib/carrierwave/storage/aws.rb', line 8 def self.connection_cache @connection_cache ||= {} end |
Instance Method Details
#cache!(file) ⇒ Object
26 27 28 29 30 |
# File 'lib/carrierwave/storage/aws.rb', line 26 def cache!(file) AWSFile.new(uploader, connection, uploader.cache_path).tap do |aws_file| aws_file.store(file) end end |
#clean_cache!(_seconds) ⇒ Object
40 41 42 |
# File 'lib/carrierwave/storage/aws.rb', line 40 def clean_cache!(_seconds) raise 'use Object Lifecycle Management to clean the cache' end |
#connection ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/carrierwave/storage/aws.rb', line 44 def connection @connection ||= begin conn_cache = self.class.connection_cache conn_cache[credentials] ||= ::Aws::S3::Resource.new(*credentials) end end |
#credentials ⇒ Object
52 53 54 |
# File 'lib/carrierwave/storage/aws.rb', line 52 def credentials [uploader.aws_credentials].compact end |
#delete_dir!(path) ⇒ Object
36 37 38 |
# File 'lib/carrierwave/storage/aws.rb', line 36 def delete_dir!(path) # NOTE: noop, because there are no directories on S3 end |
#retrieve!(identifier) ⇒ Object
22 23 24 |
# File 'lib/carrierwave/storage/aws.rb', line 22 def retrieve!(identifier) AWSFile.new(uploader, connection, uploader.store_path(identifier)) end |