Skip to content

Instantly share code, notes, and snippets.

@raykao
Forked from krames/set_temp_key.rb
Last active December 21, 2015 04:09
Show Gist options
  • Save raykao/6247498 to your computer and use it in GitHub Desktop.
Save raykao/6247498 to your computer and use it in GitHub Desktop.
Ruby script to set temp_url_key for Rackspace Cloudfiles
require 'fog'
# Please replace these with the approprate values
RACKSPACE_USERNAME = ENV['RACKSPACE_USERNAME']
RACKSPACE_API_KEY = ENV['RACKSPACE_APIKEY']
RACKSPACE_TEMP_URL_KEY = ENV['RACKSPACE_CLOUDFILES_TEMPURL_KEY'] # Self generated random string used like an auth token
puts "Creating Storage Service"
begin
service = Fog::Storage.new(
:provider => 'rackspace',
:rackspace_username => RACKSPACE_USERNAME,
:rackspace_api_key => RACKSPACE_APIKEY,
:rackspace_region => :ord
)
service.post_set_meta_temp_url_key(RACKSPACE_TEMP_URL_KEY)
puts "X-Account-Meta-Temp-Url-Key successfully set to #{RACKSPACE_TEMP_URL_KEY}"
rescue => e
puts "Unable to set X-Account-Meta-Temp-Url-Key - #{e.inspect}"
puts e.backtrace
end
@nguyenj
Copy link

nguyenj commented Jun 14, 2014

Hi, i'm currently working with rackspace cloudfiles and am trying to set a rackspace_temp_url_key. So I created a random key; but now sure where I can use or put this script? Does this script need to be in config/initializer dir?

Any help will be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment