Class: Defog::FogWrapper::Aws

Inherits:
Defog::FogWrapper show all
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

Methods inherited from Defog::FogWrapper

connect, #each, #fog_delete, #fog_head, #get_file, #put_file

Constructor Details

#initialize(opts = {}) ⇒ 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

#providerObject



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, options={})
  options = options.keyword_args(:expiry => :required, :query => :optional)
  expiry = options.delete(:expiry)
  fog_head(key).url(expiry, options)
end