Module: AWS::S3

Defined in:
lib/aws/s3/base.rb,
lib/aws/s3.rb,
lib/aws/s3/acl.rb,
lib/aws/s3/error.rb,
lib/aws/s3/owner.rb,
lib/aws/s3/bucket.rb,
lib/aws/s3/object.rb,
lib/aws/s3/version.rb,
lib/aws/s3/service.rb,
lib/aws/s3/logging.rb,
lib/aws/s3/parsing.rb,
lib/aws/s3/response.rb,
lib/aws/s3/bittorrent.rb,
lib/aws/s3/connection.rb,
lib/aws/s3/exceptions.rb,
lib/aws/s3/authentication.rb

Overview

AWS::S3 is a Ruby library for Amazon's Simple Storage Service's REST API (aws.amazon.com/s3). Full documentation of the currently supported API can be found at docs.amazonwebservices.com/AmazonS3/2006-03-01.

Getting started

To get started you need to require 'aws/s3':

% irb -rubygems
irb(main):001:0> require 'aws/s3'
# => true

The AWS::S3 library ships with an interactive shell called s3sh. From within it, you have access to all the operations the library exposes from the command line.

% s3sh
>> Version

Before you can do anything, you must establish a connection using Base.establish_connection!. A basic connection would look something like this:

AWS::S3::Base.establish_connection!(
  :access_key_id     => 'abc', 
  :secret_access_key => '123'
)

The minimum connection options that you must specify are your access key id and your secret access key.

(If you don't already have your access keys, all you need to sign up for the S3 service is an account at Amazon. You can sign up for S3 and get access keys by visiting aws.amazon.com/s3.)

For convenience, if you set two special environment variables with the value of your access keys, the console will automatically create a default connection for you. For example:

% cat .amazon_keys
export AMAZON_ACCESS_KEY_ID='abcdefghijklmnop'
export AMAZON_SECRET_ACCESS_KEY='1234567891012345'

Then load it in your shell's rc file.

% cat .zshrc
if [[ -f "$HOME/.amazon_keys" ]]; then
  source "$HOME/.amazon_keys";
fi

See more connection details at AWS::S3::Connection::Management::ClassMethods.

Defined Under Namespace

Modules: ACL, BitTorrent, Logging, Parsing, VERSION Classes: Authentication, Base, Bucket, Connection, CurrentBucketNotSpecified, DeletedObject, Error, ExceptionClassClash, FindResponseClass, InternalError, InvalidAccessControlLevel, InvalidBucketName, InvalidConnectionOption, InvalidKeyName, InvalidMetadataValue, InvalidOption, MissingAccessKey, NoBucketSpecified, NoConnectionEstablished, NoKeySpecified, NoSuchKey, Owner, RequestTimeout, ResponseError, S3Exception, S3Object, Service

Constant Summary

UNSAFE_URI =
/[^-_.!~*'()a-zA-Z\d;\/?:@&=$,\[\]]/n
Version =
[VERSION::MAJOR, VERSION::MINOR, VERSION::TINY, VERSION::BETA].compact * '.'

Class Method Summary collapse

Class Method Details

.escape_uri(path) ⇒ Object



35
36
37
# File 'lib/aws/s3.rb', line 35

def self.escape_uri(path)
  URI.escape(path.to_s, UNSAFE_URI)
end

.escape_uri_component(path) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/aws/s3.rb', line 39

def self.escape_uri_component(path)
  escaped = escape_uri(path)
  escaped.gsub!(/=/, '%3D')
  escaped.gsub!(/&/, '%26')
  escaped.gsub!(/;/, '%3B')
  escaped
end