Skip to content

Instantly share code, notes, and snippets.

@jp
Created April 24, 2013 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jp/5449809 to your computer and use it in GitHub Desktop.
Save jp/5449809 to your computer and use it in GitHub Desktop.
Generate cloudfront signed URL from a bucket
CONNECTION = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => S3_STREAMING_BUCKET[:key],
:aws_secret_access_key => S3_STREAMING_BUCKET[:secret],
:region => S3_STREAMING_BUCKET[:region]
})
S3 = CONNECTION.directories.get(S3_STREAMING_BUCKET[:bucket])
S3.files.each do |file|
puts file.key
path = AWS::CF::Signer.sign_path(
file.key,
:expires => 1.day.from_now
)
puts S3_STREAMING_BUCKET[:streaming_distribution] + "/cfx/st/" + path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment