Module: Fog::Storage::Rackspace::Common
- Defined in:
- lib/fog/rackspace/storage.rb,
lib/fog/rackspace/requests/storage/get_object_http_url.rb,
lib/fog/rackspace/requests/storage/put_object_manifest.rb,
lib/fog/rackspace/requests/storage/get_object_https_url.rb
Instance Method Summary collapse
-
#account ⇒ Fog::Storage::Rackspace::Account
Return Account Details.
- #apply_options(options) ⇒ Object
- #authenticate ⇒ Object
- #cdn ⇒ Object
- #endpoint_uri(service_endpoint_url = nil) ⇒ Object
-
#get_object_http_url(container, object, expires, options = {}) ⇒ Object
Get an expiring object http url from Cloud Files.
-
#get_object_https_url(container, object, expires, options = {}) ⇒ Object
Get an expiring object https url from Cloud Files.
-
#put_object_manifest(container, object, options = {}) ⇒ Object
Create a new dynamic large object manifest.
- #region ⇒ Object
- #request_id_header ⇒ Object
- #service_name ⇒ Object
- #service_net? ⇒ Boolean
Instance Method Details
#account ⇒ Fog::Storage::Rackspace::Account
Return Account Details
115 116 117 118 |
# File 'lib/fog/rackspace/storage.rb', line 115 def account account = Fog::Storage::Rackspace::Account.new(:service => self) account.reload end |
#apply_options(options) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fog/rackspace/storage.rb', line 47 def () @rackspace_api_key = [:rackspace_api_key] @rackspace_username = [:rackspace_username] @rackspace_cdn_ssl = [:rackspace_cdn_ssl] @rackspace_auth_url = [:rackspace_auth_url] @rackspace_servicenet = [:rackspace_servicenet] @rackspace_auth_token = [:rackspace_auth_token] @rackspace_storage_url = [:rackspace_storage_url] @rackspace_cdn_url = [:rackspace_cdn_url] @rackspace_region = [:rackspace_region] || :dfw @rackspace_temp_url_key = [:rackspace_temp_url_key] @rackspace_must_reauthenticate = false @connection_options = [:connection_options] || {} end |
#authenticate ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/fog/rackspace/storage.rb', line 81 def authenticate if @rackspace_must_reauthenticate || @rackspace_auth_token.nil? = { :rackspace_api_key => @rackspace_api_key, :rackspace_username => @rackspace_username, :rackspace_auth_url => @rackspace_auth_url, :connection_options => @connection_options } super() else @auth_token = @rackspace_auth_token @uri = URI.parse(@rackspace_storage_url) end end |
#cdn ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fog/rackspace/storage.rb', line 62 def cdn @cdn ||= Fog::CDN.new( :provider => 'Rackspace', :rackspace_api_key => @rackspace_api_key, :rackspace_auth_url => @rackspace_auth_url, :rackspace_cdn_url => @rackspace_cdn_url, :rackspace_username => @rackspace_username, :rackspace_region => @rackspace_region, :rackspace_cdn_ssl => @rackspace_cdn_ssl ) if @cdn.enabled? @cdn end end |
#endpoint_uri(service_endpoint_url = nil) ⇒ Object
108 109 110 111 |
# File 'lib/fog/rackspace/storage.rb', line 108 def endpoint_uri(service_endpoint_url=nil) return @uri if @uri super(@rackspace_storage_url || service_endpoint_url, :rackspace_storage_url) end |
#get_object_http_url(container, object, expires, options = {}) ⇒ Object
Get an expiring object http url from Cloud Files
Parameters
-
container<~String> - Name of container containing object
-
object<~String> - Name of object to get expiring url for
-
expires<~Time> - An expiry time for this url
Returns
-
response<~Excon::Response>:
-
body<~String> - url for object
-
See Also
docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
22 23 24 |
# File 'lib/fog/rackspace/requests/storage/get_object_http_url.rb', line 22 def get_object_http_url(container, object, expires, = {}) get_object_https_url(container, object, expires, .merge(:scheme => 'http')) end |
#get_object_https_url(container, object, expires, options = {}) ⇒ Object
Get an expiring object https url from Cloud Files
Parameters
-
container<~String> - Name of container containing object
-
object<~String> - Name of object to get expiring url for
-
expires<~Time> - An expiry time for this url
Returns
-
response<~Excon::Response>:
-
body<~String> - url for object
-
See Also
docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/rackspace/requests/storage/get_object_https_url.rb', line 23 def get_object_https_url(container, object, expires, = {}) if @rackspace_temp_url_key.nil? raise ArgumentError, "Storage must my instantiated with the :rackspace_temp_url_key option" end method = 'GET' expires = expires.to_i object_path_escaped = "#{@uri.path}/#{Fog::Rackspace.escape(container)}/#{Fog::Rackspace.escape(object,"/")}" object_path_unescaped = "#{@uri.path}/#{Fog::Rackspace.escape(container)}/#{object}" string_to_sign = "#{method}\n#{expires}\n#{object_path_unescaped}" hmac = Fog::HMAC.new('sha1', @rackspace_temp_url_key) sig = sig_to_hex(hmac.sign(string_to_sign)) scheme = [:scheme] ? [:scheme] : @uri.scheme "#{scheme}://#{@uri.host}#{object_path_escaped}?temp_url_sig=#{sig}&temp_url_expires=#{expires}" end |
#put_object_manifest(container, object, options = {}) ⇒ Object
Create a new dynamic large object manifest
This is an alias for #put_dynamic_obj_manifest for backward compatibility.
9 10 11 |
# File 'lib/fog/rackspace/requests/storage/put_object_manifest.rb', line 9 def put_object_manifest(container, object, = {}) put_dynamic_obj_manifest(container, object, ) end |
#region ⇒ Object
104 105 106 |
# File 'lib/fog/rackspace/storage.rb', line 104 def region @rackspace_region end |
#request_id_header ⇒ Object
100 101 102 |
# File 'lib/fog/rackspace/storage.rb', line 100 def request_id_header "X-Trans-Id" end |
#service_name ⇒ Object
96 97 98 |
# File 'lib/fog/rackspace/storage.rb', line 96 def service_name :cloudFiles end |
#service_net? ⇒ Boolean
77 78 79 |
# File 'lib/fog/rackspace/storage.rb', line 77 def service_net? @rackspace_servicenet == true end |