
# Fill in your AWS Access Key ID and Secret Access Key
# http://amazonaws.cn/security-credentials
access_key_id: <REPLACE_WITH_ACCESS_KEY_ID>
secret_access_key: <REPLACE_WITH_SECRET_ACCESS_KEY>
2. Run a sample script with the Ruby interpreter. For example, to run the s3/upload_file.rb sample:
$ echo "Hello, World!" > helloworld.txt
$ ruby s3/upload_file.rb unique-bucket-name helloworld.txt
To use the AWS Object Relational Manager (ORM) in a Rails 3 application
1. Install the gem:
$ gem install aws-sdk
2. Start a new Rails project:
$ gem install rails
$ rails new myapp
$ cd myapp/
3. Add the following line to your Gemfile:
gem 'aws-sdk'
4. Install dependencies:
$ bundle install
5. Configure AWS with your access credentials.
You can use a config initializer script (e.g., config/initializers/aws.rb) and use Ruby to
configure your AWS credentials:
AWS.config({
:access_key_id => 'REPLACE_WITH_ACCESS_KEY_ID',
:secret_access_key => 'REPLACE_WITH_SECRET_ACCESS_KEY',
})
Or you can create a config/aws.yml file that will also be automatically loaded with Rails:
# Just like config/database.yml, this file requires an entry for each envir
onment
# http://amazonaws.cn/security-credentials
development:
access_key_id: REPLACE_WITH_ACCESS_KEY_ID
secret_access_key: REPLACE_WITH_SECRET_ACCESS_KEY
Version v1.0.0
6
AWS SDK for Ruby Developer Guide
Install and Run the Samples Included in the SDK
Komentáře k této Příručce