module Fog::Storage::Rackspace::Common
Public Instance Methods
Return Account Details @return [Fog::Storage::Rackspace::Account] account details object
# File lib/fog/rackspace/storage.rb, line 120 def account account = Fog::Storage::Rackspace::Account.new(:service => self) account.reload end
# File lib/fog/rackspace/storage.rb, line 46 def apply_options(options) @rackspace_api_key = options[:rackspace_api_key] @rackspace_username = options[:rackspace_username] @rackspace_cdn_ssl = options[:rackspace_cdn_ssl] @rackspace_auth_url = options[:rackspace_auth_url] @rackspace_servicenet = options[:rackspace_servicenet] @rackspace_auth_token = options[:rackspace_auth_token] @rackspace_storage_url = options[:rackspace_storage_url] @rackspace_cdn_url = options[:rackspace_cdn_url] @rackspace_region = options[:rackspace_region] @rackspace_temp_url_key = options[:rackspace_temp_url_key] @rackspace_must_reauthenticate = false @connection_options = 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
# File lib/fog/rackspace/storage.rb, line 86 def authenticate if @rackspace_must_reauthenticate || @rackspace_auth_token.nil? options = { :rackspace_api_key => @rackspace_api_key, :rackspace_username => @rackspace_username, :rackspace_auth_url => @rackspace_auth_url, :connection_options => @connection_options } super(options) else @auth_token = @rackspace_auth_token @uri = URI.parse(@rackspace_storage_url) end end
# 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
# 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 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
-
@raise [Fog::Storage::Rackspace::NotFound] - HTTP 404 @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 @raise [Fog::Storage::Rackspace::ServiceError]
See Also¶ ↑
docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
# File lib/fog/rackspace/requests/storage/get_object_http_url.rb, line 21 def get_object_http_url(container, object, expires, options = {}) get_object_https_url(container, object, expires, options.merge(:scheme => 'http')) end
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
-
@raise [Fog::Storage::Rackspace::NotFound] - HTTP 404 @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 @raise [Fog::Storage::Rackspace::ServiceError]
See Also¶ ↑
docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
# File lib/fog/rackspace/requests/storage/get_object_https_url.rb, line 22 def get_object_https_url(container, object, expires, options = {}) if @rackspace_temp_url_key.nil? raise ArgumentError, "Storage must my instantiated with the :rackspace_temp_url_key option" end method = options[: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 = options[:scheme] ? options[:scheme] : @uri.scheme "#{scheme}://#{@uri.host}#{object_path_escaped}?temp_url_sig=#{sig}&temp_url_expires=#{expires}" end
Create a new dynamic large object manifest
This is an alias for {#put_dynamic_obj_manifest} for backward compatibility.
# File lib/fog/rackspace/requests/storage/put_object_manifest.rb, line 8 def put_object_manifest(container, object, options = {}) put_dynamic_obj_manifest(container, object, options) end
# File lib/fog/rackspace/storage.rb, line 109 def region @rackspace_region end
# File lib/fog/rackspace/storage.rb, line 105 def request_id_header "X-Trans-Id" end
# File lib/fog/rackspace/storage.rb, line 101 def service_name :cloudFiles end
# File lib/fog/rackspace/storage.rb, line 82 def service_net? @rackspace_servicenet == true end
Private Instance Methods
# File lib/fog/rackspace/requests/storage/get_object_https_url.rb, line 42 def sig_to_hex(str) str.unpack("C*").map { |c| c.to_s(16) }.map { |h| h.size == 1 ? "0#{h}" : h }.join end