|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
The AWS SDK for Ruby provides an API for Amazon S3 bucket and object operations. For object operations, you can use the API to upload objects in a single operation or upload large objects in parts (see Uploading Objects Using Multipart Upload). However, the API for a single operation upload can accept large objects as well and behind the scenes manage the upload in parts for you thereby reducing the amount of script you need to write.
When creating Amazon S3 applications using the AWS SDK for Ruby, you must install the SDK for Ruby gem. For more information, see the AWS SDK for Ruby Getting Started Guide. Once installed, you can access the API, including the following key classes:
AWS::S3—Represents the interface to Amazon S3 for the Ruby SDK.
S3 class provides the
#buckets instance method for
accessing existing buckets or creating new ones.
AWS::S3::Bucket—Represents an Amazon S3 bucket.
Bucket class provides the
method for accessing the objects in a bucket as well as methods to delete a
bucket and return information about a bucket such as the bucket
AWS::S3::S3Object—Represents an Amazon S3 object identified by its key.
S3Object class provides methods for getting and setting
properties of an object, specifying the storage class for storing objects,
and setting object permissions using access control lists. The
S3Object class also has methods for deleting,
uploading and copying objects. When uploading objects in parts, this class
provides options for you to specify the order of parts uploaded and the part
For more information about the AWS SDK for Ruby API, go to AWS SDK for Ruby API Reference.
The easiest way to get started with the Ruby script examples is to install the latest AWS SDK for Ruby gem. For information about installing or updating to the latest gem, go to http://aws.amazon.com/sdkforruby/. The following tasks guide you through the creation and testing of the Ruby script examples assuming that you have installed the AWS SDK for Ruby.
General Process of Creating and Testing Ruby Script Examples
Create a new SDK for Ruby script and add the following lines to the top of the script.
#!/usr/bin/env ruby require 'rubygems' require 'aws-sdk'
The first line is the interpreter directive and the two
AWS.config( :access_key_id => '*** Provide your access key ***, :secret_access_key => '*** Provide your secret key ***' )
Copy the code from the section you are reading to your script.
|Update the code by providing any required data. For example, if uploading a file, provide the file path and the bucket name.|
Run the script. Verify changes to buckets and objects by using the AWS Management Console. For more information about the AWS Management Console, go to http://aws.amazon.com/console/.