Sample Ruby Application for Cloud Files

  • Last updated on: 2016-04-18
  • Authored by: Rackspace Support

From Connection to Objects

In the sample command below, use your Rackspace Cloud account username and API key, where indicated by ‘UsernameGoesHere’ and ‘APIKeyGoesHere’ in the following command. For information about how to find your API key, see View and reset your API key.

#!/usr/bin/env ruby
require 'rubygems'
require 'cloudfiles'
# Log into the Cloud Files system
cf = CloudFiles::Connection.new('UsernameGoesHere','APIKeyGoesHere')
#Create a Container
container = cf.create_container('ContainerNameGoesHere')
#Create an Object
object = container.create_object('ObjectNameGoesHere')
# Write Data to an Object
object.write('DataGoesHere')

Continue the conversation in the Rackspace Community.