-
-
Save raykao/6247498 to your computer and use it in GitHub Desktop.
Ruby script to set temp_url_key for Rackspace Cloudfiles
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.