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/openstack/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/storm_on_demand/storage.rb,
lib/fog/aws/models/storage/files.rb,
lib/fog/internet_archive/storage.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/hp/models/storage/directories.rb,
lib/fog/hp/models/storage/shared_file.rb,
lib/fog/openstack/models/storage/file.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/models/storage/shared_files.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/openstack/models/storage/files.rb,
lib/fog/rackspace/models/storage/files.rb,
lib/fog/aws/requests/storage/cors_utils.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/rackspace/models/storage/account.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/rackspace/models/storage/metadata.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/models/storage/shared_directory.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/openstack/models/storage/directory.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/atmos/requests/storage/get_namespace.rb,
lib/fog/atmos/requests/storage/put_namespace.rb,
lib/fog/aws/requests/storage/get_bucket_cors.rb,
lib/fog/aws/requests/storage/put_bucket_cors.rb,
lib/fog/hp/models/storage/shared_directories.rb,
lib/fog/hp/requests/storage/delete_container.rb,
lib/fog/internet_archive/models/storage/file.rb,
lib/fog/openstack/models/storage/directories.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/hp/requests/storage/get_shared_object.rb,
lib/fog/hp/requests/storage/put_shared_object.rb,
lib/fog/internet_archive/models/storage/files.rb,
lib/fog/openstack/requests/storage/get_object.rb,
lib/fog/openstack/requests/storage/put_object.rb,
lib/fog/rackspace/requests/storage/get_object.rb,
lib/fog/rackspace/requests/storage/put_object.rb,
lib/fog/storm_on_demand/models/storage/volume.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/hp/requests/storage/head_shared_object.rb,
lib/fog/openstack/requests/storage/copy_object.rb,
lib/fog/openstack/requests/storage/head_object.rb,
lib/fog/rackspace/requests/storage/copy_object.rb,
lib/fog/rackspace/requests/storage/head_object.rb,
lib/fog/storm_on_demand/models/storage/cluster.rb,
lib/fog/storm_on_demand/models/storage/volumes.rb,
lib/fog/atmos/requests/storage/delete_namespace.rb,
lib/fog/aws/requests/storage/delete_bucket_cors.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/hp/requests/storage/get_object_temp_url.rb,
lib/fog/storm_on_demand/models/storage/clusters.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/post_object_restore.rb,
lib/fog/aws/requests/storage/put_request_payment.rb,
lib/fog/hp/requests/storage/delete_shared_object.rb,
lib/fog/hp/requests/storage/get_shared_container.rb,
lib/fog/openstack/requests/storage/delete_object.rb,
lib/fog/openstack/requests/storage/get_container.rb,
lib/fog/openstack/requests/storage/put_container.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/hp/requests/storage/head_shared_container.rb,
lib/fog/internet_archive/models/storage/directory.rb,
lib/fog/openstack/requests/storage/get_containers.rb,
lib/fog/openstack/requests/storage/head_container.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/openstack/requests/storage/head_containers.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/internet_archive/models/storage/directories.rb,
lib/fog/internet_archive/requests/storage/acl_utils.rb,
lib/fog/openstack/requests/storage/delete_container.rb,
lib/fog/rackspace/requests/storage/delete_container.rb,
lib/fog/storm_on_demand/requests/storage/get_volume.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/internet_archive/requests/storage/cors_utils.rb,
lib/fog/internet_archive/requests/storage/get_bucket.rb,
lib/fog/internet_archive/requests/storage/get_object.rb,
lib/fog/internet_archive/requests/storage/list_parts.rb,
lib/fog/internet_archive/requests/storage/put_bucket.rb,
lib/fog/internet_archive/requests/storage/put_object.rb,
lib/fog/internet_archive/requests/storage/sync_clock.rb,
lib/fog/internet_archive/models/storage/ia_attributes.rb,
lib/fog/internet_archive/requests/storage/copy_object.rb,
lib/fog/internet_archive/requests/storage/get_service.rb,
lib/fog/internet_archive/requests/storage/head_object.rb,
lib/fog/internet_archive/requests/storage/upload_part.rb,
lib/fog/storm_on_demand/requests/storage/list_volumes.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/openstack/requests/storage/put_object_manifest.rb,
lib/fog/rackspace/requests/storage/put_object_manifest.rb,
lib/fog/storm_on_demand/requests/storage/create_volume.rb,
lib/fog/storm_on_demand/requests/storage/delete_volume.rb,
lib/fog/storm_on_demand/requests/storage/list_clusters.rb,
lib/fog/storm_on_demand/requests/storage/resize_volume.rb,
lib/fog/storm_on_demand/requests/storage/update_volume.rb,
lib/fog/aws/requests/storage/get_bucket_object_versions.rb,
lib/fog/internet_archive/requests/storage/delete_bucket.rb,
lib/fog/internet_archive/requests/storage/delete_object.rb,
lib/fog/openstack/requests/storage/get_object_https_url.rb,
lib/fog/rackspace/requests/storage/get_object_https_url.rb,
lib/fog/internet_archive/requests/storage/get_bucket_acl.rb,
lib/fog/internet_archive/requests/storage/get_object_acl.rb,
lib/fog/internet_archive/requests/storage/get_object_url.rb,
lib/fog/internet_archive/requests/storage/put_bucket_acl.rb,
lib/fog/internet_archive/requests/storage/put_object_acl.rb,
lib/fog/internet_archive/requests/storage/put_object_url.rb,
lib/fog/internet_archive/requests/storage/get_bucket_cors.rb,
lib/fog/internet_archive/requests/storage/put_bucket_cors.rb,
lib/fog/rackspace/requests/storage/delete_multiple_objects.rb,
lib/fog/rackspace/requests/storage/put_static_obj_manifest.rb,
lib/fog/internet_archive/requests/storage/get_bucket_policy.rb,
lib/fog/internet_archive/requests/storage/put_bucket_policy.rb,
lib/fog/rackspace/requests/storage/put_dynamic_obj_manifest.rb,
lib/fog/internet_archive/requests/storage/delete_bucket_cors.rb,
lib/fog/internet_archive/requests/storage/get_bucket_logging.rb,
lib/fog/internet_archive/requests/storage/get_bucket_website.rb,
lib/fog/internet_archive/requests/storage/get_object_torrent.rb,
lib/fog/internet_archive/requests/storage/put_bucket_logging.rb,
lib/fog/internet_archive/requests/storage/put_bucket_website.rb,
lib/fog/internet_archive/requests/storage/get_bucket_location.rb,
lib/fog/internet_archive/requests/storage/get_object_http_url.rb,
lib/fog/internet_archive/requests/storage/get_request_payment.rb,
lib/fog/internet_archive/requests/storage/put_request_payment.rb,
lib/fog/openstack/requests/storage/post_set_meta_temp_url_key.rb,
lib/fog/rackspace/requests/storage/delete_static_large_object.rb,
lib/fog/rackspace/requests/storage/post_set_meta_temp_url_key.rb,
lib/fog/internet_archive/requests/storage/delete_bucket_policy.rb,
lib/fog/internet_archive/requests/storage/get_bucket_lifecycle.rb,
lib/fog/internet_archive/requests/storage/get_object_https_url.rb,
lib/fog/internet_archive/requests/storage/put_bucket_lifecycle.rb,
lib/fog/internet_archive/requests/storage/delete_bucket_website.rb,
lib/fog/internet_archive/requests/storage/abort_multipart_upload.rb,
lib/fog/internet_archive/requests/storage/list_multipart_uploads.rb,
lib/fog/storm_on_demand/requests/storage/attach_volume_to_server.rb,
lib/fog/internet_archive/requests/storage/delete_bucket_lifecycle.rb,
lib/fog/internet_archive/requests/storage/delete_multiple_objects.rb,
lib/fog/storm_on_demand/requests/storage/detach_volume_from_server.rb,
lib/fog/internet_archive/requests/storage/complete_multipart_upload.rb,
lib/fog/internet_archive/requests/storage/initiate_multipart_upload.rb,
lib/fog/internet_archive/requests/storage/post_object_hidden_fields.rb
Defined Under Namespace
Modules: IAAttributes
Classes: AWS, Atmos, Google, HP, IBM, InternetArchive, Local, Ninefold, OpenStack, Rackspace, StormOnDemand
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
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/fog/storage.rb', line 27
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/fog/storage.rb', line 38
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
53
54
55
56
57
58
59
60
|
# File 'lib/fog/storage.rb', line 53
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
|
# 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 :internetarchive
require 'fog/internet_archive/storage'
Fog::Storage::InternetArchive.new(attributes)
when :stormondemand
require 'fog/storm_on_demand/storage'
Fog::Storage::StormOnDemand.new(attributes)
else
if self.providers.include?(provider)
require "fog/#{provider}/storage"
return Fog::Storage.const_get(Fog.providers[provider]).new(attributes)
end
raise ArgumentError.new("#{provider} is not a recognized storage provider")
end
end
|
.parse_data(data) ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/fog/storage.rb', line 62
def self.parse_data(data)
{
:body => data,
:headers => {
'Content-Length' => get_body_size(data),
'Content-Type' => get_content_type(data)
}
}
end
|
.providers ⇒ Object
73
74
75
|
# File 'lib/fog/storage.rb', line 73
def self.providers
Fog.services[:storage]
end
|