Module: Fog::Storage
- Defined in:
- lib/fog/storage.rb,
lib/fog/hp/storage.rb,
lib/fog/aws/storage.rb,
lib/fog/ibm/storage.rb,
lib/fog/atmos/storage.rb,
lib/fog/local/storage.rb,
lib/fog/google/storage.rb,
lib/fog/ninefold/storage.rb,
lib/fog/nirvanix/storage.rb,
lib/fog/rackspace/storage.rb,
lib/fog/hp/models/storage/file.rb,
lib/fog/aws/models/storage/file.rb,
lib/fog/hp/models/storage/files.rb,
lib/fog/aws/models/storage/files.rb,
lib/fog/atmos/models/storage/file.rb,
lib/fog/ibm/models/storage/volume.rb,
lib/fog/local/models/storage/file.rb,
lib/fog/atmos/models/storage/files.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/hp/models/storage/directory.rb,
lib/fog/ibm/models/storage/offering.rb,
lib/fog/aws/models/storage/directory.rb,
lib/fog/ibm/models/storage/offerings.rb,
lib/fog/nirvanix/models/storage/file.rb,
lib/fog/hp/models/storage/directories.rb,
lib/fog/nirvanix/models/storage/files.rb,
lib/fog/rackspace/models/storage/file.rb,
lib/fog/atmos/models/storage/directory.rb,
lib/fog/aws/models/storage/directories.rb,
lib/fog/aws/requests/storage/acl_utils.rb,
lib/fog/hp/requests/storage/get_object.rb,
lib/fog/hp/requests/storage/put_object.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/hp/requests/storage/head_object.rb,
lib/fog/ibm/requests/storage/get_volume.rb,
lib/fog/atmos/models/storage/directories.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/hp/requests/storage/delete_object.rb,
lib/fog/hp/requests/storage/get_container.rb,
lib/fog/hp/requests/storage/put_container.rb,
lib/fog/ibm/requests/storage/list_volumes.rb,
lib/fog/nirvanix/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/hp/requests/storage/get_containers.rb,
lib/fog/hp/requests/storage/head_container.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/hp/requests/storage/head_containers.rb,
lib/fog/ibm/requests/storage/list_offerings.rb,
lib/fog/nirvanix/models/storage/directories.rb,
lib/fog/atmos/requests/storage/get_namespace.rb,
lib/fog/atmos/requests/storage/put_namespace.rb,
lib/fog/hp/requests/storage/delete_container.rb,
lib/fog/nirvanix/requests/storage/get_object.rb,
lib/fog/rackspace/models/storage/directories.rb,
lib/fog/atmos/requests/storage/head_namespace.rb,
lib/fog/atmos/requests/storage/post_namespace.rb,
lib/fog/google/requests/storage/delete_bucket.rb,
lib/fog/google/requests/storage/delete_object.rb,
lib/fog/nirvanix/requests/storage/list_folder.rb,
lib/fog/nirvanix/requests/storage/upload_file.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/atmos/requests/storage/delete_namespace.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/nirvanix/requests/storage/create_folder.rb,
lib/fog/nirvanix/requests/storage/delete_folder.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/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/nirvanix/requests/storage/get_optimal_url.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/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/aws/requests/storage/delete_multiple_objects.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,
lib/fog/rackspace/requests/storage/get_object_https_url.rb,
lib/fog/rackspace/requests/storage/post_set_meta_temp_url_key.rb
Defined Under Namespace
Classes: AWS, Atmos, Google, HP, IBM, Local, Ninefold, Nirvanix, 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
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/fog/storage.rb', line 43
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/fog/storage.rb', line 54
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
69
70
71
72
73
74
75
76
|
# File 'lib/fog/storage.rb', line 69
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
33
34
35
36
37
38
39
40
41
|
# 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 :atmos
require 'fog/atmos/storage'
Fog::Storage::Atmos.new(attributes)
when :aws
require 'fog/aws/storage'
Fog::Storage::AWS.new(attributes)
when :google
require 'fog/google/storage'
Fog::Storage::Google.new(attributes)
when :hp
require 'fog/hp/storage'
Fog::Storage::HP.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 :nirvanix
require 'fog/nirvanix/storage'
Fog::Storage::Nirvanix.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
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/fog/storage.rb', line 78
def self.parse_data(data)
{
:body => data,
:headers => {
'Content-Length' => get_body_size(data),
'Content-Type' => get_content_type(data)
}
}
end
|
.providers ⇒ Object
89
90
91
|
# File 'lib/fog/storage.rb', line 89
def self.providers
Fog.services[:storage]
end
|