Class: AWS::S3::Website
- Extended by:
- Content
- Defined in:
- lib/aws/s3/website.rb,
lib/aws/s3/response.rb
Overview
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')
Defined Under Namespace
Instance Attribute Summary
Attributes included from Content
Class Method Summary collapse
-
.create(name = nil, index_page = "index.html", error_page = "error.html") ⇒ Object
To enable a bucket as a website you just specify its name.
-
.delete(name = nil, options = {}) ⇒ Object
disables a bucket aswebsite.
-
.find(name = nil) ⇒ Object
Fetches if a bucket is website enabled.
Instance Method Summary collapse
Methods included from Content
Methods inherited from Base
current_bucket, #initialize, request, set_current_bucket_to
Constructor Details
This class inherits a constructor from AWS::S3::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AWS::S3::Base
Class Method Details
.create(name = nil, index_page = "index.html", error_page = "error.html") ⇒ Object
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")
56 57 58 |
# File 'lib/aws/s3/website.rb', line 56 def create(name=nil, index_page="index.html", error_page="error.html") put(path(name), {}, Builder.new(index_page, error_page).to_s).success? end |
.delete(name = nil, options = {}) ⇒ Object
disables a bucket aswebsite.
Website.delete('photos')
74 75 76 |
# File 'lib/aws/s3/website.rb', line 74 def delete(name = nil, = {}) Base.delete(path(name)).success? end |
.find(name = nil) ⇒ Object
Fetches if a bucket is website enabled.
website=Website.find('jukebox')
website.index_doc
=> 'index.html'
website.error_doc
=> 'error.html'
68 69 70 |
# File 'lib/aws/s3/website.rb', line 68 def find(name = nil) new(get(path(name)).website) end |
Instance Method Details
#error_doc ⇒ Object
96 97 98 |
# File 'lib/aws/s3/website.rb', line 96 def error_doc self.error_document["key"] end |
#index_doc ⇒ Object
92 93 94 |
# File 'lib/aws/s3/website.rb', line 92 def index_doc self.index_document["suffix"] end |