Class: AWS::S3::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/s3/connection.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Management Classes: Options

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Connection

Creates a new connection. Connections make the actual requests to S3, though these requests are usually called from subclasses of Base.

For details on establishing connections, check the Connection::Management::ClassMethods.



16
17
18
19
# File 'lib/aws/s3/connection.rb', line 16

def initialize(options = {})
  @options = Options.new(options)
  connect
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



79
80
81
# File 'lib/aws/s3/connection.rb', line 79

def method_missing(method, *args, &block)
  options[method] || super
end

Instance Attribute Details

#access_key_idObject (readonly)

Returns the value of attribute access_key_id.



10
11
12
# File 'lib/aws/s3/connection.rb', line 10

def access_key_id
  @access_key_id
end

#httpObject (readonly)

Returns the value of attribute http.



10
11
12
# File 'lib/aws/s3/connection.rb', line 10

def http
  @http
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/aws/s3/connection.rb', line 10

def options
  @options
end

#secret_access_keyObject (readonly)

Returns the value of attribute secret_access_key.



10
11
12
# File 'lib/aws/s3/connection.rb', line 10

def secret_access_key
  @secret_access_key
end

Class Method Details

.connect(options = {}) ⇒ Object



5
6
7
# File 'lib/aws/s3/connection.rb', line 5

def connect(options = {})
  new(options)
end

Instance Method Details

#protocol(options = {}) ⇒ Object



46
47
48
# File 'lib/aws/s3/connection.rb', line 46

def protocol(options = {})
  (options[:use_ssl] || http.use_ssl?) ? 'https://' : 'http://'
end

#request(verb, path, headers = {}, body = nil, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/aws/s3/connection.rb', line 21

def request(verb, path, headers = {}, body = nil, &block)
  http.start do
    request = request_method(verb).new(path, headers)
    authenticate!(request)
    case body
    when String then request.body = body
    when IO     then
      request.body_stream    = body
      request.content_length = body.lstat.size
    end if body
    http.request(request, &block)
  end
end

#subdomainObject



42
43
44
# File 'lib/aws/s3/connection.rb', line 42

def subdomain
  http.address[/^([^.]+).#{DEFAULT_HOST}$/, 1]
end

#url_for(path, options = {}) ⇒ Object



35
36
37
38
39
40
# File 'lib/aws/s3/connection.rb', line 35

def url_for(path, options = {})
  path         = URI.escape(path)
  request      = request_method(:get).new(path, {})
  query_string = query_string_authentication(request, options)
  "#{protocol(options)}#{http.address}#{path}?#{query_string}"
end