Module: Fog::Storage
- Defined in:
- lib/fog/storage.rb,
lib/fog/aws/storage.rb,
lib/fog/ibm/storage.rb,
lib/fog/local/storage.rb,
lib/fog/google/storage.rb,
lib/fog/ninefold/storage.rb,
lib/fog/rackspace/storage.rb,
lib/fog/aws/models/storage/file.rb,
lib/fog/aws/models/storage/files.rb,
lib/fog/ibm/models/storage/volume.rb,
lib/fog/local/models/storage/file.rb,
lib/fog/aws/models/storage/version.rb,
lib/fog/google/models/storage/file.rb,
lib/fog/ibm/models/storage/volumes.rb,
lib/fog/local/models/storage/files.rb,
lib/fog/aws/models/storage/versions.rb,
lib/fog/google/models/storage/files.rb,
lib/fog/ibm/models/storage/offering.rb,
lib/fog/aws/models/storage/directory.rb,
lib/fog/ibm/models/storage/offerings.rb,
lib/fog/ninefold/models/storage/file.rb,
lib/fog/ninefold/models/storage/files.rb,
lib/fog/rackspace/models/storage/file.rb,
lib/fog/aws/models/storage/directories.rb,
lib/fog/aws/requests/storage/acl_utils.rb,
lib/fog/local/models/storage/directory.rb,
lib/fog/rackspace/models/storage/files.rb,
lib/fog/aws/requests/storage/get_bucket.rb,
lib/fog/aws/requests/storage/get_object.rb,
lib/fog/aws/requests/storage/list_parts.rb,
lib/fog/aws/requests/storage/put_bucket.rb,
lib/fog/aws/requests/storage/put_object.rb,
lib/fog/aws/requests/storage/sync_clock.rb,
lib/fog/google/models/storage/directory.rb,
lib/fog/ibm/requests/storage/get_volume.rb,
lib/fog/aws/requests/storage/copy_object.rb,
lib/fog/aws/requests/storage/get_service.rb,
lib/fog/aws/requests/storage/head_object.rb,
lib/fog/aws/requests/storage/upload_part.rb,
lib/fog/local/models/storage/directories.rb,
lib/fog/google/models/storage/directories.rb,
lib/fog/ibm/requests/storage/list_volumes.rb,
lib/fog/ninefold/models/storage/directory.rb,
lib/fog/aws/requests/storage/delete_bucket.rb,
lib/fog/aws/requests/storage/delete_object.rb,
lib/fog/google/requests/storage/get_bucket.rb,
lib/fog/google/requests/storage/get_object.rb,
lib/fog/google/requests/storage/put_bucket.rb,
lib/fog/google/requests/storage/put_object.rb,
lib/fog/ibm/requests/storage/create_volume.rb,
lib/fog/ibm/requests/storage/delete_volume.rb,
lib/fog/rackspace/models/storage/directory.rb,
lib/fog/aws/requests/storage/get_bucket_acl.rb,
lib/fog/aws/requests/storage/get_object_acl.rb,
lib/fog/aws/requests/storage/get_object_url.rb,
lib/fog/aws/requests/storage/put_bucket_acl.rb,
lib/fog/aws/requests/storage/put_object_acl.rb,
lib/fog/aws/requests/storage/put_object_url.rb,
lib/fog/google/requests/storage/copy_object.rb,
lib/fog/google/requests/storage/get_service.rb,
lib/fog/google/requests/storage/head_object.rb,
lib/fog/ibm/requests/storage/list_offerings.rb,
lib/fog/ninefold/models/storage/directories.rb,
lib/fog/rackspace/models/storage/directories.rb,
lib/fog/google/requests/storage/delete_bucket.rb,
lib/fog/google/requests/storage/delete_object.rb,
lib/fog/rackspace/requests/storage/get_object.rb,
lib/fog/rackspace/requests/storage/put_object.rb,
lib/fog/aws/requests/storage/get_bucket_policy.rb,
lib/fog/aws/requests/storage/put_bucket_policy.rb,
lib/fog/google/requests/storage/get_object_acl.rb,
lib/fog/google/requests/storage/get_object_url.rb,
lib/fog/google/requests/storage/put_bucket_acl.rb,
lib/fog/google/requests/storage/put_object_url.rb,
lib/fog/rackspace/requests/storage/copy_object.rb,
lib/fog/rackspace/requests/storage/head_object.rb,
lib/fog/aws/requests/storage/get_bucket_logging.rb,
lib/fog/aws/requests/storage/get_bucket_website.rb,
lib/fog/aws/requests/storage/get_object_torrent.rb,
lib/fog/aws/requests/storage/put_bucket_logging.rb,
lib/fog/aws/requests/storage/put_bucket_website.rb,
lib/fog/ninefold/requests/storage/get_namespace.rb,
lib/fog/ninefold/requests/storage/put_namespace.rb,
lib/fog/aws/requests/storage/get_bucket_location.rb,
lib/fog/aws/requests/storage/get_object_http_url.rb,
lib/fog/aws/requests/storage/get_request_payment.rb,
lib/fog/aws/requests/storage/put_request_payment.rb,
lib/fog/ninefold/requests/storage/head_namespace.rb,
lib/fog/ninefold/requests/storage/post_namespace.rb,
lib/fog/rackspace/requests/storage/delete_object.rb,
lib/fog/rackspace/requests/storage/get_container.rb,
lib/fog/rackspace/requests/storage/put_container.rb,
lib/fog/aws/requests/storage/delete_bucket_policy.rb,
lib/fog/aws/requests/storage/get_bucket_lifecycle.rb,
lib/fog/aws/requests/storage/get_object_https_url.rb,
lib/fog/aws/requests/storage/put_bucket_lifecycle.rb,
lib/fog/rackspace/requests/storage/get_containers.rb,
lib/fog/rackspace/requests/storage/head_container.rb,
lib/fog/aws/requests/storage/delete_bucket_website.rb,
lib/fog/aws/requests/storage/get_bucket_versioning.rb,
lib/fog/aws/requests/storage/put_bucket_versioning.rb,
lib/fog/google/requests/storage/get_object_torrent.rb,
lib/fog/ninefold/requests/storage/delete_namespace.rb,
lib/fog/rackspace/requests/storage/head_containers.rb,
lib/fog/aws/requests/storage/abort_multipart_upload.rb,
lib/fog/aws/requests/storage/list_multipart_uploads.rb,
lib/fog/google/requests/storage/get_object_http_url.rb,
lib/fog/rackspace/requests/storage/delete_container.rb,
lib/fog/aws/requests/storage/delete_bucket_lifecycle.rb,
lib/fog/google/requests/storage/get_object_https_url.rb,
lib/fog/aws/requests/storage/complete_multipart_upload.rb,
lib/fog/aws/requests/storage/initiate_multipart_upload.rb,
lib/fog/aws/requests/storage/post_object_hidden_fields.rb,
lib/fog/rackspace/requests/storage/put_object_manifest.rb,
lib/fog/aws/requests/storage/get_bucket_object_versions.rb
Defined Under Namespace
Classes: AWS, Google, IBM, Local, Ninefold, Rackspace
Class Method Summary
collapse
Class Method Details
.[](provider) ⇒ Object
4
5
6
|
# File 'lib/fog/storage.rb', line 4
def self.[](provider)
self.new(:provider => provider)
end
|
.directories ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/fog/storage.rb', line 34
def self.directories
directories = []
for provider in self.providers
begin
directories.concat(self[provider].directories)
rescue end
end
directories
end
|
.get_body_size(body) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/fog/storage.rb', line 45
def self.get_body_size(body)
if body.respond_to?(:force_encoding)
body.force_encoding('BINARY')
end
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
end
|
.get_content_type(data) ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/fog/storage.rb', line 60
def self.get_content_type(data)
if data.respond_to?(:path) and !data.path.nil?
filename = ::File.basename(data.path)
unless (mime_types = MIME::Types.of(filename)).empty?
mime_types.first.content_type
end
end
end
|
.new(attributes) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/fog/storage.rb', line 8
def self.new(attributes)
attributes = attributes.dup case provider = attributes.delete(:provider).to_s.downcase.to_sym
when :aws
require 'fog/aws/storage'
Fog::Storage::AWS.new(attributes)
when :google
require 'fog/google/storage'
Fog::Storage::Google.new(attributes)
when :ibm
require 'fog/ibm/storage'
Fog::Storage::IBM.new(attributes)
when :local
require 'fog/local/storage'
Fog::Storage::Local.new(attributes)
when :ninefold
require 'fog/ninefold/storage'
Fog::Storage::Ninefold.new(attributes)
when :rackspace
require 'fog/rackspace/storage'
Fog::Storage::Rackspace.new(attributes)
else
raise ArgumentError.new("#{provider} is not a recognized storage provider")
end
end
|
.parse_data(data) ⇒ Object
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/fog/storage.rb', line 69
def self.parse_data(data)
{
:body => data,
:headers => {
'Content-Length' => get_body_size(data),
'Content-Type' => get_content_type(data)
}
}
end
|
.providers ⇒ Object
80
81
82
|
# File 'lib/fog/storage.rb', line 80
def self.providers
Fog.services[:storage]
end
|