Ruby client library for the Google Storage API
This is the first release and supports all the basic operations. Advanced support for ACLs etc.. coming soon
Install the gem
sudo gem install gstore
Using the gem
Visit The Google Storage Key Manager to get your access and secret keys.
In your code just: require 'gstore'
Example
Create an instance of the client with your credentials:
client = GStore::Client.new(
:access_key => 'YOUR_ACCESS_KEY',
:secret_key => 'YOUR_SECRET_KEY'
)
# List all of your existing Buckets
client.list_buckets
Here are some example bucket operations:
# Create a Bucket
client.create_bucket('my_unique_bucket')
# Retrieve a Bucket
client.get_bucket('my_unique_bucket')
# Delete a [empty] Bucket
client.delete_bucket('my_unique_bucket')
Once you have a bucket you can manipulate objects in the following way:
# Store a file in a bucket
client.put_object('my_unique_bucket', 'my_first_object', :data => File.read('mytext.txt'))
# Retrieve the contents of the object in the specified bucket
puts client.get_object('my_unique_bucket', 'my_first_object')
# Alternatively specify an outfile and the contents will be saved to there
client.get_object('my_unique_bucket', 'my_first_object', :outfile => 'retrieved_mytext.txt')
# Delete an object from the bucket
client.delete_object('my_unique_bucket', 'my_first_object')