Last active
August 29, 2015 14:01
-
-
Save bradgignac/1dcb1561973d3abd3ecf to your computer and use it in GitHub Desktop.
Enable CORS with Fog
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
gem install fog | |
ruby enable-cors.rb RACKSPACE_USERNAME RACKSPACE_API_KEY CONTAINER_NAME |
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
require 'fog' | |
username, api_key, container = ARGV | |
connection = Fog::Storage.new(provider: 'Rackspace', rackspace_username: username, rackspace_api_key: api_key) | |
container = connection.directories.get(container) | |
puts "Enabling CORS for #{container}..." | |
container.files.each do |file| | |
begin | |
print " #{file.key}... " | |
file.access_control_allow_origin = '*' | |
file.save | |
puts "Complete!" | |
rescue => e | |
puts "Failed!" | |
puts "Script Error: #{e}" | |
break | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment