
If successful, the sample will output the S3 URL of the file that you just uploaded, with an option to delete
it:
Uploaded test.png to:
https://s3.amazonaws.com/my_test_bucket/test.png
Use this URL to download the file:
https://s3.amazonaws.com/my_test_bucket/test.png
(press any key to delete the object)
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://aws.amazon.com/security-credentials
development:
access_key_id: REPLACE_WITH_ACCESS_KEY_ID
Version v1.0.0
23
AWS SDK for Ruby Developer Guide
Run the Samples
Komentáře k této Příručce