Class: AzureBlob::CanonicalizedResource
- Inherits:
-
Object
- Object
- AzureBlob::CanonicalizedResource
- Defined in:
- lib/azure_blob/canonicalized_resource.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(uri, account_name, service_name: nil, url_safe: true) ⇒ CanonicalizedResource
constructor
A new instance of CanonicalizedResource.
- #to_s ⇒ Object
Constructor Details
#initialize(uri, account_name, service_name: nil, url_safe: true) ⇒ CanonicalizedResource
Returns a new instance of CanonicalizedResource.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/azure_blob/canonicalized_resource.rb', line 5 def initialize(uri, account_name, service_name: nil, url_safe: true) # This next line is needed because CanonicalizedResource # need to be escaped for auhthorization headers, but not SAS tokens path = url_safe ? uri.path : URI::RFC2396_PARSER.unescape(uri.path) resource = "/#{account_name}#{path.empty? ? "/" : path}" resource = "/#{service_name}#{resource}" if service_name params = CGI.parse(uri.query.to_s) .transform_keys(&:downcase) .sort .map { |param, value| "#{param}:#{value.map(&:strip).sort.join(",")}" } @canonicalized_resource = [ resource, *params ].join("\n") end |
Instance Method Details
#to_s ⇒ Object
19 20 21 |
# File 'lib/azure_blob/canonicalized_resource.rb', line 19 def to_s @canonicalized_resource end |