Amazon's S3 storage service + Ruby

03 Apr 2006

If you're using Amazon's S3 service with Ruby 1.8.4, you'll probably get this error at some point:

./S3.rb:49:in `canonical_string': undefined method `strip' 
for ["Sat, 01 Apr 2006 05:13:01 GMT"]:Array (NoMethodError)
from ./S3.rb:43:in `canonical_string'
from ./S3.rb:220:in `set_aws_auth_header'
from ./S3.rb:186:in `make_request'
from /usr/lib/ruby/1.8/net/http.rb:545:in `start'
from ./S3.rb:180:in `make_request'
from ./S3.rb:119:in `create_bucket'
from s3-driver.rb:24 

To fix this, see William Strand's post; basically, just edit line 49 of S3.rb and change it to:

interesting_headers[lk] = value.to_s.strip

To get the tests in s3-tests.rb to run I also needed to change line 156 to:

req['Content-Length'] = data.length.to_s

With these changes all seems well; I'm able (while working on indi) to create buckets, upload files, and so on.