Module: Fog::Rackspace::Files

Defined in:
lib/fog/rackspace/files.rb,
lib/fog/rackspace/models/files/file.rb,
lib/fog/rackspace/models/files/files.rb,
lib/fog/rackspace/models/files/directory.rb,
lib/fog/rackspace/models/files/directories.rb,
lib/fog/rackspace/requests/files/get_object.rb,
lib/fog/rackspace/requests/files/put_object.rb,
lib/fog/rackspace/requests/files/head_object.rb,
lib/fog/rackspace/requests/files/delete_object.rb,
lib/fog/rackspace/requests/files/get_container.rb,
lib/fog/rackspace/requests/files/put_container.rb,
lib/fog/rackspace/requests/files/get_containers.rb,
lib/fog/rackspace/requests/files/head_container.rb,
lib/fog/rackspace/requests/files/head_containers.rb,
lib/fog/rackspace/requests/files/delete_container.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
# File 'lib/fog/rackspace/files.rb', line 5

def self.new(options={})

  require 'fog/rackspace/models/files/directory'
  require 'fog/rackspace/models/files/directories'
  require 'fog/rackspace/models/files/file'
  require 'fog/rackspace/models/files/files'
  require 'fog/rackspace/requests/files/delete_container'
  require 'fog/rackspace/requests/files/delete_object'
  require 'fog/rackspace/requests/files/get_container'
  require 'fog/rackspace/requests/files/get_containers'
  require 'fog/rackspace/requests/files/get_object'
  require 'fog/rackspace/requests/files/head_container'
  require 'fog/rackspace/requests/files/head_containers'
  require 'fog/rackspace/requests/files/head_object'
  require 'fog/rackspace/requests/files/put_container'
  require 'fog/rackspace/requests/files/put_object'

  if Fog.mocking?
    Fog::Rackspace::Files::Mock.new(options)
  else
    Fog::Rackspace::Files::Real.new(options)
  end
end

.parse_data(data) ⇒ Object


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/rackspace/files.rb', line 29

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


50
51
52
# File 'lib/fog/rackspace/files.rb', line 50

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