Class: Aws::CloudFront::UrlSigner
- Inherits:
-
Object
- Object
- Aws::CloudFront::UrlSigner
- Includes:
- Signer
- Defined in:
- lib/aws-sdk-cloudfront/url_signer.rb
Overview
Allows you to create signed URLs for Amazon CloudFront resources
signer = Aws::CloudFront::UrlSigner.new(
key_pair_id: "cf-keypair-id",
private_key_path: "./cf_private_key.pem"
)
url = signer.signed_url(url,
policy: policy.to_json
)
Instance Method Summary collapse
-
#signed_url(url, params = {}) ⇒ Object
create a signed Amazon CloudFront URL.
Methods included from Signer
Instance Method Details
#signed_url(url, params = {}) ⇒ Object
create a signed Amazon CloudFront URL
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/aws-sdk-cloudfront/url_signer.rb', line 27 def signed_url(url, params = {}) scheme, uri = scheme_and_uri(url) signed_content = signature( resource: resource(scheme, uri), expires: time(params[:expires]), policy: params[:policy] ) start_flag = URI.parse(uri).query ? '&' : '?' signature = signed_content.map{ |k, v| "#{k}=#{v}" }.join('&').gsub("\n", '') uri = "#{uri}#{start_flag}#{signature}" if scheme == 'rtmp' rtmp_url(URI(uri)) else uri end end |