Use Gem's "AWS --SDK".
gem "aws-sdk"
KEY_PAIR_ID: ID of the key pair created by CloudFront PRIVATE_KEY: Contents of the private key of the key pair created by CloudFront
class ApplicationUploader < CarrierWave::Uploader::Base
def signed_url
if path.blank?
url
else
signer = Aws::CloudFront::UrlSigner.new(key_pair_id: KEY_PAIR_ID, private_key: PRIVATE_KEY)
signer.signed_url(url, expires: Time.zone.now + 5.minutes)
end
end
end
[AWS] How to set a signed URL in CloudFront (delivery of private content)
Recommended Posts