Class: Uploadcare::SignedUrlGenerators::AkamaiGenerator
- Inherits:
-
BaseGenerator
- Object
- BaseGenerator
- Uploadcare::SignedUrlGenerators::AkamaiGenerator
- Defined in:
- lib/uploadcare/signed_url_generators/akamai_generator.rb
Constant Summary collapse
- UUID_REGEX =
'[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}'
- TEMPLATE =
'https://{cdn_host}/{uuid}/?token=exp={expiration}{delimiter}acl={acl}{delimiter}hmac={token}'
Instance Attribute Summary
Attributes inherited from BaseGenerator
#algorithm, #cdn_host, #secret_key, #ttl
Instance Method Summary collapse
Methods inherited from BaseGenerator
Constructor Details
This class inherits a constructor from Uploadcare::SignedUrlGenerators::BaseGenerator
Instance Method Details
#generate_url(uuid, acl = uuid, wildcard: false) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/uploadcare/signed_url_generators/akamai_generator.rb', line 11 def generate_url(uuid, acl = uuid, wildcard: false) raise ArgumentError, 'Must contain valid UUID' unless valid?(uuid) formatted_acl = build_acl(uuid, acl, wildcard: wildcard) expire = build_expire signature = build_signature(expire, formatted_acl) TEMPLATE.gsub('{delimiter}', delimiter) .sub('{cdn_host}', sanitized_string(cdn_host)) .sub('{uuid}', sanitized_string(uuid)) .sub('{acl}', formatted_acl) .sub('{expiration}', expire) .sub('{token}', signature) end |