class Openstack::Client::Storage::CreateTemporaryURI
Create a tempory URL according to OpenStack specification. More details here: docs.openstack.org/swift/latest/api/temporary_url_middleware.html
Attributes
http_method[R]
options[R]
uri[R]
Public Class Methods
new(uri:, http_method:, options: {})
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 13 def initialize(uri:, http_method:, options: {}) @uri = uri @http_method = http_method @options = options end
Public Instance Methods
generate()
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 19 def generate add_params uri end
Private Instance Methods
add_params()
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 26 def add_params uri.query = URI.encode_www_form( temp_url_sig: signature, temp_url_expires: expires_in, filename: filename, disposition => nil ) end
algorithm()
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 53 def algorithm 'SHA1' end
disposition()
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 49 def disposition options.fetch(:disposition) { 'inline' } end
expires_in()
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 39 def expires_in @expires_in ||= options.fetch(:expires_in) do 15.minutes end.from_now.to_i end
filename()
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 45 def filename options.fetch(:filename) { File.basename(uri.path) } end
hmac_body()
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 63 def hmac_body [http_method, expires_in, uri.path].join("\n") end
signature()
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 35 def signature OpenSSL::HMAC.hexdigest(algorithm, temporary_url_key, hmac_body) end
temporary_url_key()
click to toggle source
# File lib/openstack/client/storage/create_temporary_uri.rb, line 57 def temporary_url_key options.fetch(:temporary_url_key) do Rails.application.credentials.openstack.fetch(:temporary_url_key) end end