Class: Defog::FogWrapper::Aws
- Inherits:
-
Defog::FogWrapper
- Object
- Defog::FogWrapper
- Defog::FogWrapper::Aws
- Defined in:
- lib/defog/fog_wrapper.rb
Instance Attribute Summary
Attributes inherited from Defog::FogWrapper
#fog_connection, #fog_directory, #location, #logger, #prefix
Instance Method Summary collapse
- #get_md5(key) ⇒ Object
-
#initialize(opts = {}) ⇒ Aws
constructor
A new instance of Aws.
- #provider ⇒ Object
- #url(key, options = {}) ⇒ Object
Methods inherited from Defog::FogWrapper
connect, #each, #fog_delete, #fog_head, #get_file, #put_file
Constructor Details
#initialize(opts = {}) ⇒ Aws
Returns a new instance of Aws.
108 109 110 111 112 113 114 115 |
# File 'lib/defog/fog_wrapper.rb', line 108 def initialize(opts={}) super(opts) opts = opts.keyword_args(:aws_access_key_id => :required, :aws_secret_access_key => :required, :region => :optional, :bucket => :required) @location = opts.delete(:bucket) @fog_connection = (@@aws_connection_cache||={})[opts] ||= Fog::Storage.new(opts.merge(:provider => provider)) @fog_connection.directories.create :key => @location unless @fog_connection.directories.map(&:key).include? @location @fog_directory = @fog_connection.directories.get(@location, :prefix => @prefix) end |
Instance Method Details
#get_md5(key) ⇒ Object
117 118 119 |
# File 'lib/defog/fog_wrapper.rb', line 117 def get_md5(key) fog_head(key).etag end |
#provider ⇒ Object
106 |
# File 'lib/defog/fog_wrapper.rb', line 106 def provider ; :AWS ; end |
#url(key, options = {}) ⇒ Object
121 122 123 124 125 |
# File 'lib/defog/fog_wrapper.rb', line 121 def url(key, ={}) = .keyword_args(:expiry => :required, :query => :optional) expiry = .delete(:expiry) fog_head(key).url(expiry, ) end |