Library for accessing S3 objects and buckets, supports EU and US buckets
Ruby
Pull request Compare This branch is 115 commits behind qoobaa:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
extra
lib
test
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
s3.gemspec

README.md

S3

S3 library provides access to Amazon's Simple Storage Service.

It supports both: European and US buckets through the REST API.

Click here to lend your support to: S3 and make a donation at www.pledgie.com!

Installation

gem install s3

Usage

Initialize the service

require "s3"
service = S3::Service.new(:access_key_id => "...",
                          :secret_access_key => "...")
#=> #<S3::Service:...>

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>

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

See also

Copyright

Copyright (c) 2009 Jakub Kuźma, Mirosław Boruta. See LICENSE for details.