Fog storage tutorial sample running on Ninefold
Keys can be obtained from the portal under 'My Details'
Clone this gist, then:
bundle install
./storage_tut.rb <Atmos Access Token> <Atmos shared secret>
source :rubygems | |
gem 'fog', :git => 'https://github.com/ninefold/fog.git', :branch => 'ninefold_storage' | |
#gem 'fog', :path => '/Users/lstoll/dev/ninefold/fog' |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'bundler' | |
Bundler.require | |
# From http://fog.io/0.9.0/storage/ | |
unless ARGV.size == 2 | |
puts "Pass in the Access Token and Shared Secret on the command line. See _README.md" | |
exit | |
end | |
# create a connection | |
connection = Fog::Storage.new({ | |
:provider => 'Ninefold', | |
:ninefold_storage_token => ARGV[0], | |
:ninefold_storage_secret => ARGV[1] | |
}) | |
# First, a place to contain the glorious details | |
directory = connection.directories.create( | |
:key => "fog-demo-#{Time.now.to_i}", # globally unique name | |
:public => true | |
) | |
# list directories | |
p connection.directories | |
# upload that resume | |
file = directory.files.create( | |
:key => 'super_page.html', | |
:body => File.open("super_page.html"), | |
:public => true, | |
:content_type => 'text/html' | |
) | |
# Re-upload, demo's updating | |
file.body = File.open("super_page.html") | |
file.save | |
# Write the public URL to this file | |
puts file.public_url | |
# Wait, then destroy | |
puts "Test the URL, then press return to remove them.." | |
STDIN.gets | |
file.destroy | |
directory.destroy |
<html> | |
<body> | |
<h1>SUPER!</h1> | |
</body> | |
</html> |