Module: Fog::Rackspace::Storage::Utils

Included in:
Mock, Real
Defined in:
lib/fog/rackspace/storage.rb

Instance Method Summary collapse

Instance Method Details

#cdnObject



27
28
29
30
31
32
# File 'lib/fog/rackspace/storage.rb', line 27

def cdn
  @cdn ||= Fog::Rackspace::CDN.new(
    :rackspace_api_key => @rackspace_api_key,
    :rackspace_username => @rackspace_username
  )
end

#parse_data(data) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/rackspace/storage.rb', line 34

def 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