53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/fog/storage/rackspace.rb', line 53
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
|