Skip to content

Instantly share code, notes, and snippets.

@baldowl
Created January 26, 2011 07:04
Show Gist options
  • Save baldowl/796353 to your computer and use it in GitHub Desktop.
Save baldowl/796353 to your computer and use it in GitHub Desktop.
Interactive fog session: how to get a bunch of signed URLs for European buckets with fog 0.4.1
require 'active_support/time'
bucket = AWS.directories.select {|d| d.key == 'my_bucket'}
files = bucket.files.select {|f| f.content_length > 0 &&
f.key =~ %r{client-name.*\.zip}}
expiration = Time.now.next_month.end_of_month
signed_urls = files.map {|f| f.url(expiration)}
fixed_signed_url = signed_urls.map do |su|
su.sub(%r{s3\.(.*)/my_bucket}, "my_bucket.s3.#{$1}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment