Permalink
Browse files

website enable

  • Loading branch information...
suratpyari committed Mar 14, 2012
1 parent f1f9787 commit 0eeb90afea58f506b43becdd5259484fa044f381
Showing with 56 additions and 11 deletions.
  1. +1 −5 INSTALL
  2. +25 −0 README
  3. +6 −0 README.erb
  4. +0 −4 lib/aws/s3/base.rb
  5. +24 −2 lib/aws/s3/bucket.rb
View
@@ -2,11 +2,7 @@
The easiest way to install aws/s3 is with Rubygems:
- % sudo gem i aws-s3 -ry
-
-== Directly from svn
-
- % svn co svn://rubyforge.org/var/svn/amazon/s3/trunk aws
+ % sudo gem i surat-aws-s3 -ry
== As a Rails plugin
View
25 README
@@ -1,4 +1,5 @@
= AWS::S3
+Forked from https://github.com/marcel/aws-s3
AWS::S3 is a Ruby library for Amazon's Simple Storage Service's REST API (http://aws.amazon.com/s3).
Full documentation of the currently supported API can be found at http://docs.amazonwebservices.com/AmazonS3/2006-03-01.
@@ -63,6 +64,9 @@ Buckets are containers for objects (the files you store on S3). To create a new
# Pick a unique name, or else you'll get an error
# if the name is already taken.
Bucket.create('jukebox')
+
+ To add location
+ Bucket.create('jukebox', {}, "EU")
Bucket names must be unique across the entire S3 system, sort of like domain names across the internet. If you try
to create a bucket with a name that is already taken, you will get an error.
@@ -498,6 +502,27 @@ Disabling logging is just as simple as enabling it:
Bucket.disable_logging_for('jukebox')
+== Website
+==== Enable bucket as website
+To enable a bucket as a website you just specify its name.
+
+ Pick a existing bucket name, or else you'll get an error
+ Website.create('jukebox')
+ By default index document is "index.html" and error document is "error.html"
+
+ If Its different you can do
+ Website.create('jukebox', "about.html", "404.html")
+
+
+Once you have succesfully enabled as website you can you can fetch it by name using Website.find.
+
+ music_website = Website.find('jukebox')
+
+The bucket that is not website enabled will will throw an error.
+
+You can remove website from bucket using Website.delete.
+
+ Website.delete('jukebox')
== Errors
==== When things go wrong
View
@@ -1,4 +1,5 @@
= AWS::S3
+Forked from https://github.com/marcel/aws-s3
<%= docs_for['AWS::S3'] %>
@@ -47,6 +48,11 @@ The three main concepts of S3 are the service, buckets and objects.
<%= docs_for['AWS::S3::Logging'] %>
+== Website
+==== Enable a bucket as website
+
+<%= docs_for['AWS::S3::Website'] %>
+
== Errors
==== When things go wrong
View
@@ -64,10 +64,6 @@ class << self
# It is unlikely that you would call this method directly. Subclasses of Base have convenience methods for each http request verb
# that wrap calls to request.
def request(verb, path, options = {}, body = nil, attempts = 0, &block)
- if options[:body] and body.nil?
- body=options[:body]
- # options.delete(:body)
- end
Service.response = nil
process_options!(options, verb)
response = response_class.new(connection.request(verb, path, options, body, attempts, &block))
View
@@ -5,6 +5,8 @@ module S3
# # Pick a unique name, or else you'll get an error
# # if the name is already taken.
# Bucket.create('jukebox')
+ # To add location
+ # Bucket.create('jukebox', {}, "EU")
#
# Bucket names must be unique across the entire S3 system, sort of like domain names across the internet. If you try
# to create a bucket with a name that is already taken, you will get an error.
@@ -59,6 +61,23 @@ module S3
# Bucket.delete('photos', :force => true)
# # => true
class Bucket < Base
+
+ class Builder < XmlGenerator #:nodoc:
+ attr_reader :location
+ def initialize(location)
+ @location = location
+ super()
+ end
+
+ def build
+ return nil unless @location
+ xml.tag!('CreateBucketConfiguration', 'xmlns' => 'http://s3.amazonaws.com/doc/2006-03-01/') do
+ xml.LocationConstraint @location
+ end
+ end
+ end
+
+
class << self
# Creates a bucket named <tt>name</tt>.
#
@@ -71,12 +90,15 @@ class << self
# By default new buckets have their access level set to private. You can override this using the <tt>:access</tt> option.
#
# Bucket.create('internet_drop_box', :access => :public_read_write)
+
+ # If you want to change default location
+ # Bucket.create('internet_drop_box', {}, "EU")
#
# The full list of access levels that you can set on Bucket and S3Object creation are listed in the README[link:files/README.html]
# in the section called 'Setting access levels'.
- def create(name, options = {})
+ def create(name, options = {}, location=nil)
validate_name!(name)
- put("/#{name}", options).success?
+ put("/#{name}", options, Builder.new(location).to_s).success?
end
# Fetches the bucket named <tt>name</tt>.

0 comments on commit 0eeb90a

Please sign in to comment.