This gem is used to access ceph storage and to create radosgw-admin user.
gem install radosgw-s3
radosgw-admin guide to create radosgw user.
require "radosgw-s3" service = CEPH::User.new(:ipaddress => "RADOSGW_HOST_IP", :username => "RADOSGW_HOST_USERNAME", :user_password => "RADOSGW_HOST_USER_PASSWORD", )
service.create("UID_NAME", "DISPLAY_NAME")
It will give you the access_key and secret_key in hash format
{"access_key"=>"8OC3R0QYPOW9TWE6M4L7", "secret_key"=>"+dDV9U+0hx7VufeFGWvF+34AC9g1IcrsIrOzLtZL"}
service.usage("UID_NAME")
It will return something like
{"total_objects"=>"2", "total_bytes"=>"102400", "last_update"=>"2015-10-09 05:45:02.466953Z"}
radosgw-S3 library provides access to Ceph’s radosgw storage.
require "radosgw-s3" service = S3::Service.new(:access_key_id => "...", :secret_access_key => "...", :host => "127.0.0.1", :port => 8000 # Defaults to 443 or 80 if not set )
service.buckets #=> [#<S3::Bucket:first-bucket>, # #<S3::Bucket:second-bucket>]
first_bucket = service.buckets.find("first-bucket") #=> #<S3::Bucket:first-bucket>
new_bucket = service.buckets.build("newbucketname") new_bucket.save(:location => :eu)
first_bucket.objects #=> [#<S3::Object:/first-bucket/lenna.png>, # #<S3::Object:/first-bucket/lenna_mini.png>]
object = first_bucket.objects.find("lenna.png") #=> #<S3::Object:/first-bucket/lenna.png>
object.content_type #=> "image/png"
object.content #=> "\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00..."
object.destroy #=> true
new_object = bucket.objects.build("bender.png") #=> #<S3::Object:/synergy-staging/bender.png> new_object.content = open("bender.png") new_object.save #=> true
Please note that new objects are created with “private” ACL by default.
object = bucket.objects.find('lenna.png') object.request_acl # or bucket.request_acl
This will return hash with all users/groups and theirs permissions
object = bucket.objects.find("lenna.png") object.copy(:key => "lenna.png", :bucket => bucket, :acl => :public_read)
See LICENSE for details.