Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ Before you can do anything, you must establish a connection using Base.establish

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

For Walrus, or other requiring a different path for connection, one can use the :path option:

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

(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 http://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:
Expand Down Expand Up @@ -542,4 +550,4 @@ get to the last request's response via Service.response.
This is also useful when an error exception is raised in the console which you weren't expecting. You can
root around in the response to get more details of what might have gone wrong.



7 changes: 5 additions & 2 deletions lib/aws/s3/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def request(verb, path, headers = {}, body = nil, attempts = 0, &block)

requester = Proc.new do
path = self.class.prepare_path(path) if attempts.zero? # Only escape the path once
if options[:path]!=nil
path = options[:path]+path
end
request = request_method(verb).new(path, headers)
ensure_content_type!(request)
add_user_agent!(request)
Expand Down Expand Up @@ -249,7 +252,7 @@ def default_connection
end

class Options < Hash #:nodoc:
VALID_OPTIONS = [:access_key_id, :secret_access_key, :server, :port, :use_ssl, :persistent, :proxy].freeze
VALID_OPTIONS = [:access_key_id, :secret_access_key, :server, :port, :use_ssl, :persistent, :proxy, :path].freeze

def initialize(options = {})
super()
Expand All @@ -275,4 +278,4 @@ def validate(options)
end
end
end
end
end
24 changes: 20 additions & 4 deletions lib/aws/s3/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ def inspect
class Bucket
class Response < Base::Response
def bucket
parsed
if ! parsed['list_bucket_response'].nil?
return parsed['list_bucket_response']
elsif ! parsed['list_bucket_result'].nil?
return parsed['list_bucket_result']
else
return parsed
end
end
end
end
Expand All @@ -81,11 +87,21 @@ def etag
class Service
class Response < Base::Response
def empty?
parsed['buckets'].nil?
if parsed['buckets'].nil?
# Walrus model
return parsed['list_all_my_buckets_response']['buckets'].nil?
end
return false
end

def buckets
parsed['buckets']['bucket'] || []
if ! parsed['buckets'].nil?
parsed['buckets']['bucket']
elsif ! parsed['list_all_my_buckets_response']['buckets'].nil?
parsed['list_all_my_buckets_response']['buckets']['bucket']
else
[]
end
end
end
end
Expand Down Expand Up @@ -177,4 +193,4 @@ def truncate(klass)
end
end
end
#:startdoc:
#:startdoc: