Last active
August 29, 2015 13:57
-
-
Save cktricky/9358979 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cf_url is http://dSomething.cloudfront.net/path | |
# video_name is test.mp4 | |
def signed_html5 | |
parsed_uri = URI.parse(cf_url) | |
url = "#{parsed_uri.scheme}://#{parsed_uri.host}#{parsed_uri.path}/#{video_name}" | |
signed_url = sign(url) | |
end | |
# cf_url is http://dSomething.cloudfront.net/path | |
# video_name is test.mp4 | |
def signed_flash | |
path = URI.parse(cf_url).path[/\/+(.*)/, 1] | |
rtmp_url = "rtmp://someRandomSubDomain.cloudfront.net:1935/cfx/st/mp4:" | |
rtmp_path = sign("#{path}/#{video_name}") | |
full_url = "#{rtmp_url}#{rtmp_path}" | |
end | |
def sign(url="") | |
# 1 hour expiration on the URL | |
url = SIGNER.sign(url.to_s, :ending => Time.now + 3600) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment