Sha256: 09dfbb5520d8e190cc369996815903bcaa38c537fa0bc1bf048b0f04796f4bf5
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
begin # Use mime/types/columnar if available, for reduced memory usage require "mime/types/columnar" rescue LoadError require "mime/types" end module Fog module Storage extend Fog::ServicesMixin def self.directories directories = [] providers.each do |provider| begin directories.concat(self[provider].directories) rescue # ignore any missing credentials/etc end end directories end def self.get_body_size(body) if body.respond_to?(:encoding) original_encoding = body.encoding body = body.dup if body.frozen? body = body.force_encoding("BINARY") end size = if body.respond_to?(:bytesize) body.bytesize elsif body.respond_to?(:size) body.size elsif body.respond_to?(:stat) body.stat.size else 0 end if body.respond_to?(:encoding) body.force_encoding(original_encoding) end size end def self.get_content_type(data) if data.respond_to?(:path) && !data.path.nil? filename = ::File.basename(data.path) unless (mime_types = MIME::Types.of(filename)).empty? mime_types.first.content_type end end end def self.parse_data(data) { body: data, headers: { "Content-Length" => get_body_size(data), "Content-Type" => get_content_type(data) } } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fog-core-2.6.0 | lib/fog/storage.rb |
fog-core-2.5.0 | lib/fog/storage.rb |