Release: AWS SDK for Ruby 1.2.4

Release Notes>Ruby>Release: AWS SDK for Ruby 1.2.4
This minor release adds a few features and fixes a few bugs.

Details

Submitted By: trevor@AWS
Release Date: December 8, 2011 12:54 AM GMT
Latest Version: 1.2.4
Created On: December 8, 2011 12:54 AM GMT
Last Updated: December 8, 2011 12:54 AM GMT

Latest Version

Download the latest version of the AWS SDK for Ruby:

gem install aws-sdk

New Features

Change Description
Persistent HTTP Connections

The default request handler (AWS::Core::Http::NetHttpHandler) now uses persistent connections. A connection pool is employed to share connections between threads and to clean up idle connections.

Amazon S3 Multi-object delete support

The AWS SDK for Ruby now supports multi-object deletes for Amazon S3

bucket = AWS::S3.new.buckets['mybucket']

# delete a list of objects by keys, objects are deleted in batches of 1k per
# request.  Accepts strings, AWS::S3::S3Object, AWS::S3::ObectVersion and 
# hashes with :key and :version_id
bucket.objects.delete('key1', 'key2', 'key3', ...)

# delete all of the objects in a bucket (optionally with a common prefix as shown)
bucket.objects.with_prefix('2009/').delete_all

# conditional delete, loads and deletes objects in batches of 1k, only
# deleting those that return true from the block
bucket.objects.delete_if{|object| object.key =~ /\.pdf$/ }

# empty the bucket and then delete the bucket, objects are deleted in batches of 1k
bucket.delete!
AWS::S3::S3Object#read :range

Added better support for reading byte ranges of an object via AWS::S3::S3Object.

# read the first 1KB of data from an object
object = AWS::S3.new.buckets['mybucket'].objects['key']
object.read(:range => 0..1023)
Added date attributes to AWS::Record::Base

You can now store dates (without times) as AWS::Record attributes.

class Product < AWS::Record::Base
  date_attr :introduced_on
end

product = Product.new(:introduced_on => Time.now)
product.introduced_on #=> #<Date: 4911805/2,0,2299161>
product.introduced_on.to_s #=> '2011-12-07'
AWS::Record::Base sharding new records

When creating a new record you can now specify which domain you want it stored in. This will override where it will save.

class Product < AWS::Record::Base
  set_domain_name('products-a')
end

Product.new.domain #=> 'products-a'
Product.new(:domain => 'products-b').domain #=> 'products-b'
Product.domain('products-c').new.domain #=> 'product-c'

AWS::Record::Base#domain is a read only attribute for records, so it must be set when constructed (via a scope chain or #initialize).

AWS::Record constructing with attributes from scope

You can now construct objects from where scopes and domain scopes.

class Product < AWS::Record::Base

  string_attr :title
  string_attr :category

  scope :books, where(:category => 'books')
  scope :a_to_l, domain('products-1')
  scope :m_to_z, domain('products-2')

end

product = Product.books.a_to_l.new(:title => 'A Big Book')
product.category #=> 'books'
product.title #=> 'A Big Book'
product.domain #=> 'products-1'

Limit and order scopes have no effect on constructed records. Only hash-style where-conditions can be applied.

Resolved Issues

Change Description
Updating Cache-Control header in Amazon S3

AWS::S3::S3Object#copy_from and #copy_to failed to properly support the cache control header. This has been fixed.

# update the cache control header
object = AWS::S3.new.buckets['mybucket'].objects['key']
object.copy_to(object.key, :cache_control => "max-age=2592000")
AWS::S3::PresignedPost now supports sessions

If you provide credentials with a session token to AWS::S3 you can now generated presigned posts using those credentials. Previously the security token was omited from the post, causing this to fail.

Amazon S3 multipart-upload fix

A bug was resolved that caused AWS::S3::S3Object.write to complete a multipart upload of large objects if an error was raised during the upload.

Now the upload will be aborted if an error (StandardError) is raised. If an exception (e.g. control-c) is triggered, then the multipart upload will be left.

Supported API Versions

This release of the SDK supports the following API versions:

Service API Version
Amazon Elastic Compute Cloud 2011-02-28
Amazon SimpleDB 2009-04-15
Amazon Simple E-mail Service 2010-12-01
Amazon Simple Notifications Service 2010-03-31
Amazon Simple Queue Service 2009-02-01
Amazon Simple Storage Service 2006-03-01
AWS Identity and Access Management 2010-05-08
AWS Security Token Service 2011-06-15
Elastic Load Balancing 2011-08-15
©2014, Amazon Web Services, Inc. or its affiliates. All rights reserved.