Project

radosgw-s3

0.02
No commit activity in last 3 years
No release in over 3 years
radosgw-s3 library provides access to your ceph-radosgw. It supports both: radosgw user creation and bucket operation using REST API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 1.8
~> 1.1
~> 10.4
~> 3.1

Runtime

~> 3.0
~> 0.2.0
 Project Readme

radosgw-S3¶ ↑

This gem is used to access ceph storage and to create radosgw-admin user.

Installation¶ ↑

gem install radosgw-s3

Ceph-radosgw user¶ ↑

radosgw-admin guide to create radosgw user.

Usage¶ ↑

Initialize the service¶ ↑

require "radosgw-s3"
service = CEPH::User.new(:ipaddress => "RADOSGW_HOST_IP",
                          :username => "RADOSGW_HOST_USERNAME",
                          :user_password => "RADOSGW_HOST_USER_PASSWORD",
)

create user¶ ↑

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"}

Get user Usage¶ ↑

service.usage("UID_NAME")

It will return something like

{"total_objects"=>"2", "total_bytes"=>"102400", "last_update"=>"2015-10-09 05:45:02.466953Z"}

See also¶ ↑

radosgw-S3¶ ↑

radosgw-S3 library provides access to Ceph’s radosgw storage.

Initialize the service¶ ↑

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
                         )

List buckets¶ ↑

service.buckets
#=> [#<S3::Bucket:first-bucket>,
#    #<S3::Bucket:second-bucket>]

Find bucket¶ ↑

first_bucket = service.buckets.find("first-bucket")
#=> #<S3::Bucket:first-bucket>

Create bucket¶ ↑

new_bucket = service.buckets.build("newbucketname")
new_bucket.save(:location => :eu)

List objects in a bucket¶ ↑

first_bucket.objects
#=> [#<S3::Object:/first-bucket/lenna.png>,
#    #<S3::Object:/first-bucket/lenna_mini.png>]

Find object in a bucket¶ ↑

object = first_bucket.objects.find("lenna.png")
#=> #<S3::Object:/first-bucket/lenna.png>

Access object metadata (cached from find)¶ ↑

object.content_type
#=> "image/png"

Access object content (downloads the object)¶ ↑

object.content
#=> "\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00..."

Delete an object¶ ↑

object.destroy
#=> true

Create an object¶ ↑

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.

Fetch ACL¶ ↑

object = bucket.objects.find('lenna.png')
object.request_acl # or bucket.request_acl

This will return hash with all users/groups and theirs permissions

Modify ACL¶ ↑

object = bucket.objects.find("lenna.png")
object.copy(:key => "lenna.png", :bucket => bucket, :acl => :public_read)

See also¶ ↑

See LICENSE for details.