Module: Fog::Storage
Constant Summary
Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT, Fog::ServicesMixin::E_SERVICE_PROVIDER_PATH
Class Method Summary
collapse
[], new, providers
Class Method Details
.directories ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/fog/storage.rb', line 12
def self.directories
directories = []
providers.each do |provider|
begin
directories.concat(self[provider].directories)
rescue end
end
directories
end
|
.get_body_size(body) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/fog/storage.rb', line 23
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
|
.get_content_type(data) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/fog/storage.rb', line 47
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
|
.parse_data(data) ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/fog/storage.rb', line 56
def self.parse_data(data)
{
body: data,
headers: {
"Content-Length" => get_body_size(data),
"Content-Type" => get_content_type(data)
}
}
end
|