Module: Fog::AWS::S3

Defined in:
lib/fog/aws/s3.rb,
lib/fog/aws/models/s3/file.rb,
lib/fog/aws/models/s3/files.rb,
lib/fog/aws/models/s3/directory.rb,
lib/fog/aws/models/s3/directories.rb,
lib/fog/aws/requests/s3/get_bucket.rb,
lib/fog/aws/requests/s3/get_object.rb,
lib/fog/aws/requests/s3/put_bucket.rb,
lib/fog/aws/requests/s3/put_object.rb,
lib/fog/aws/requests/s3/copy_object.rb,
lib/fog/aws/requests/s3/get_service.rb,
lib/fog/aws/requests/s3/head_object.rb,
lib/fog/aws/requests/s3/delete_bucket.rb,
lib/fog/aws/requests/s3/delete_object.rb,
lib/fog/aws/requests/s3/get_bucket_location.rb,
lib/fog/aws/requests/s3/get_request_payment.rb,
lib/fog/aws/requests/s3/put_request_payment.rb

Defined Under Namespace

Classes: Directories, Directory, File, Files, Mock, Real

Class Method Summary collapse

Class Method Details

.new(options = {}) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/aws/s3.rb', line 5

def self.new(options={})

  require 'fog/aws/models/s3/directories'
  require 'fog/aws/models/s3/directory'
  require 'fog/aws/models/s3/files'
  require 'fog/aws/models/s3/file'
  require 'fog/aws/requests/s3/copy_object'
  require 'fog/aws/requests/s3/delete_bucket'
  require 'fog/aws/requests/s3/delete_object'
  require 'fog/aws/requests/s3/get_bucket'
  require 'fog/aws/requests/s3/get_bucket_location'
  require 'fog/aws/requests/s3/get_object'
  require 'fog/aws/requests/s3/get_request_payment'
  require 'fog/aws/requests/s3/get_service'
  require 'fog/aws/requests/s3/head_object'
  require 'fog/aws/requests/s3/put_bucket'
  require 'fog/aws/requests/s3/put_object'
  require 'fog/aws/requests/s3/put_request_payment'

  if Fog.mocking?
    Fog::AWS::S3::Mock.new(options)
  else
    Fog::AWS::S3::Real.new(options)
  end
end

.parse_data(data) ⇒ Object


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/aws/s3.rb', line 31

def self.parse_data(data)
   = {
    :body => nil,
    :headers => {}
  }

  if data.is_a?(String)
    [:body] = data
    [:headers]['Content-Length'] = [:body].size.to_s
  else
    filename = ::File.basename(data.path)
    unless (mime_types = MIME::Types.of(filename)).empty?
      [:headers]['Content-Type'] = mime_types.first.content_type
    end
    [:body] = data.read
    [:headers]['Content-Length'] = ::File.size(data.path).to_s
  end
  # metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
  
end

.reset_data(keys = Mock.data.keys) ⇒ Object


52
53
54
# File 'lib/fog/aws/s3.rb', line 52

def self.reset_data(keys=Mock.data.keys)
  Mock.reset_data(keys)
end