27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/fog/rackspace/storage.rb', line 27
def parse_data(data)
metadata = {
:body => nil,
:headers => {}
}
if data.is_a?(String)
metadata[:body] = data
metadata[:headers]['Content-Length'] = metadata[:body].size.to_s
else
filename = ::File.basename(data.path)
unless (mime_types = MIME::Types.of(filename)).empty?
metadata[:headers]['Content-Type'] = mime_types.first.content_type
end
metadata[:body] = data.read
metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
end
metadata
end
|