Amazon Simple Storage Service

Amazon S3 Library for REST in Ruby

Click for a printer friendly version of this document Printer Friendly Save to del.icio.us
Average Review:

A library in Ruby for working with the Amazon S3 REST interface.

Submitted By: EricW@AWS  
AWS Products Used: Amazon S3
Language(s): Ruby
License: New BSD

About This Sample

  • A library in Ruby for working with the Amazon S3 REST interface.
  • Part of a collection of interface libraries, each in a different language.
  • Updated on 2006-06-16 to use the list delimiter.
  • See the README file in the download for more information about the sample.

What's New?

  • 2007-11-05: Updates to support EU
  • 2007-05-18: Updates to support signed HTTP requests to virtual hosted buckets.
  • 2006-10-02: Updates for server access logging.
  • 2006-06-28:  Fixed query string authentication tests.

Prerequisites

Running the Sample

  • See the README file in the attached download for information on running the sample.


Related Documents
Type: Sample Code Amazon S3 Redirects Sample in Ruby

Discussion

The 5 most recent discussion messages. View full discussion.

Peter Alvin
RealName(TM)
Posts: 4
Registered: 7/22/08
Amazon S3 Library for REST in Ruby--How Upload File?
Posted: Sep 24, 2008 7:19 PM PDT
 
  Click to reply to this thread Reply

How do you use the S3Object to encapsulate a file?  I'm trying to upload a JPEG.  Could somebody please paste some Ruby code?  I'm thinking it will look something like this:

   response =
      @conn.put(
        'myBUcket',
        'myImage.jpg',
        S3::S3Object.new(text, {'title' => title_with_spaces}),  <---HELP HERE
                {    'Content-Type' => 'image/jpeg',
                    'x-amz-acl' => 'public-read'})




Reviews
Create Review Write a Review

Not impressed with the ruby on rails support, May 6, 2007 3:05 PM
Reviewer: Ryan Hanks
First of all, I think it's a little confusing to distribute the library files for using the Amazon S3 in Ruby on Rails through the "Code Samples" folder. Package it up in a gem and get it listed in one of the primary Gem repositories. I couldn't get the included tests to run: Loaded suite s3-test Started EF Finished in 75.264583 seconds. 1) Error: test_operations(TC_AWSAuthConnectionTest): Errno::ETIMEDOUT: Operation timed out - connect(2) /usr/local/lib/ruby/1.8/net/http.rb:560:in `initialize' /usr/local/lib/ruby/1.8/net/http.rb:560:in `open' /usr/local/lib/ruby/1.8/net/http.rb:560:in `connect' /usr/local/lib/ruby/1.8/timeout.rb:48:in `timeout' /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout' /usr/local/lib/ruby/1.8/net/http.rb:560:in `connect' /usr/local/lib/ruby/1.8/net/http.rb:553:in `do_start' /usr/local/lib/ruby/1.8/net/http.rb:542:in `start' ./S3.rb:194:in `make_request' ./S3.rb:125:in `create_bucket' s3-test.rb:27:in `test_operations' 2) Failure: test_operations(TC_QueryStringAuthGeneratorTest) [s3-test.rb:243:in `check_url' /usr/local/lib/ruby/1.8/net/http.rb:543:in `start' s3-test.rb:231:in `check_url' s3-test.rb:250:in `test_operations']: create_bucket. > expected to be an instance of but was . 2 tests, 1 assertions, 1 failures, 1 errors

Make me a gem, May 21, 2007 11:26 AM
Reviewer: jumb0
I agree. You guys did a great job but it would be nice if all I had to type was script/plugin install ... or gem install.

Problems with tests, Jun 21, 2007 2:25 AM
Reviewer: Giovanni Intini
The first time you run the test suite you get two errors: 1) Failure: test_operations(TC_AWSAuthConnectionTest) [s3-test.rb:196:in `verify_list_bucket_response' s3-test.rb:213:in `do_delimited_list' s3-test.rb:62:in `test_operations' s3-test.rb:35:in `each' s3-test.rb:35:in `test_operations']: bucket name should match. expected but was . 2) Failure: test_operations(TC_QueryStringAuthGeneratorTest) [s3-test.rb:254:in `check_url' C:/ruby/lib/ruby/1.8/net/http.rb:543:in `start' s3-test.rb:242:in `check_url' s3-test.rb:298:in `test_operations' s3-test.rb:265:in `each' s3-test.rb:265:in `test_operations']: delete bucket. > expected to be an instance of but was . From the second time and going on you get a different error in place of the first one (you keep getting the second): 1) Failure: test_operations(TC_AWSAuthConnectionTest) method test_operations in s3-test.rb at line 45 method each in s3-test.rb at line 37 method test_operations in s3-test.rb at line 37 bucket is empty. expected but was . That's no good.
Welcome, Guest Help
Login Login