0.0
No commit activity in last 3 years
No release in over 3 years
Use cryptkeeper to talk to Google Storage
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

CryptKeeper¶ ↑

Rails gem for connecting to the Google Storage API

Install¶ ↑

gem install cryptkeeper

Depending upon how your environment is set up, you may also need:

require 'crypt_keeper'

Usage¶ ↑

So far:

keeper = CryptKeeper::Connection.new({:access_key => 'your_access_key', :secret_key => 'your_secret_key'})

See all of my buckets

puts keeper.buckets.each do |bucket|
    puts bucket.name
    puts bucket.created_at
end

Search for all files that start with “Picture” The following returns meta info on each of the found objects within the specified bucket

metas = keeper.bucket_meta_objects('adam_first_bucket', {:prefix => 'Picture'})

Now it’s time to grab the actual object (data) I am writing it to Files here on my local machine

metas.each do |meta|
    puts meta.key # In my case, prints Picture 1.png
    f = File.new("/Users/user/Desktop/#{meta.key}",'w')
    # object method will go and fetch it unless it's been fetched before
    # if you want to force another trip to the Crypt, do meta.object!
    f.write(meta.object)
    f.close()
end

Creates 3 new picture files on my Desktop: Picture 1.png, Picture 2.png, Picture 3.png

Add a new object to a bucket

new_bucket = keeper.create_bucket({:name => "adam_new_bucket3"})

data = File.open("/Users/user/Desktop/Picture 3.png", "rb")
new_bucket.add_object('Picture 5.png', data, 'image/png')

data = File.open("/Users/user/Desktop/text_file.txt", 'r')
new_bucket.add_object("myTextFile.txt", data) # if you don't specify a content type, binary/octet-stream is used

Copy an object from one bucket to another

# Fetch an object
my_object = keeper.bucket_meta_objects('adam_new_bucket3', {:prefix => 'Picture%205.png'}).first

# Copy an object to another bucket
my_object.copy_to 'adam_first_bucket' # copy to a different bucket and keep the path intact
my_object.copy_to 'adam_new_bucket', 'path_1/path_2/path_3/Picture5.png' # copy to a different bucket and path

Delete an object

my_object.delete

Delete an object

keeper.bucket_meta_objects('adam_new_bucket3', {:prefix => 'Picture%205.png'}).first.delete