lib/fog/storage.rb in fog-0.6.0 vs lib/fog/storage.rb in fog-0.7.0
- old
+ new
@@ -19,7 +19,28 @@
else
raise ArgumentError.new("#{provider} is not a recognized storage provider")
end
end
+ def self.parse_data(data)
+ metadata = {
+ :body => nil,
+ :headers => {}
+ }
+
+ if data.is_a?(String)
+ metadata[:body] = data
+ metadata[:headers]['Content-Length'] = metadata[:body].size
+ 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
+ metadata[:headers]['Content-Length'] = ::File.size(data.path)
+ end
+ # metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
+ metadata
+ end
+
end
end
\ No newline at end of file