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
120 121 122 123 |
# File 'lib/fog/rackspace/storage.rb', line 120 def account account = Fog::Storage::Rackspace::Account.new(:service => self) account.reload end |
#apply_options(options) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fog/rackspace/storage.rb', line 46 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] @rackspace_temp_url_key = [:rackspace_temp_url_key] @rackspace_must_reauthenticate = false @connection_options = [:connection_options] || {} unless @rackspace_region || (@rackspace_storage_url && @rackspace_cdn_url) Fog::Logger.deprecation("Default region support will be removed in an upcoming release. Please switch to manually setting your endpoint. This requires settng the :rackspace_region option.") end @rackspace_region ||= :dfw end |
#authenticate ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/fog/rackspace/storage.rb', line 86 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
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fog/rackspace/storage.rb', line 67 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
113 114 115 116 |
# File 'lib/fog/rackspace/storage.rb', line 113 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
21 22 23 |
# File 'lib/fog/rackspace/requests/storage/get_object_http_url.rb', line 21 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
-
options<~Hash> - Options to override the method or scheme
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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fog/rackspace/requests/storage/get_object_https_url.rb', line 22 def get_object_https_url(container, object, expires, = {}) if @rackspace_temp_url_key.nil? raise ArgumentError, "Storage must be instantiated with the :rackspace_temp_url_key option" end method = [: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)) temp_url_query = { :temp_url_sig => sig, :temp_url_expires => expires } temp_url_query.merge!(:inline => true) if [:inline] temp_url_query.merge!(:filename => [:filename]) if [:filename] = { :scheme => [:scheme] || @uri.scheme, :host => @uri.host, :path => object_path_escaped, :query => temp_url_query.map { |param, val| "#{CGI.escape(param.to_s)}=#{CGI.escape(val.to_s)}" }.join('&') } URI::Generic.build().to_s 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.
8 9 10 |
# File 'lib/fog/rackspace/requests/storage/put_object_manifest.rb', line 8 def put_object_manifest(container, object, = {}) put_dynamic_obj_manifest(container, object, ) end |
#region ⇒ Object
109 110 111 |
# File 'lib/fog/rackspace/storage.rb', line 109 def region @rackspace_region end |
#request_id_header ⇒ Object
105 106 107 |
# File 'lib/fog/rackspace/storage.rb', line 105 def request_id_header "X-Trans-Id" end |
#service_name ⇒ Object
101 102 103 |
# File 'lib/fog/rackspace/storage.rb', line 101 def service_name :cloudFiles end |
#service_net? ⇒ Boolean
82 83 84 |
# File 'lib/fog/rackspace/storage.rb', line 82 def service_net? @rackspace_servicenet == true end |