Method: Aws::S3::Bucket.create

Defined in:
lib/s3/bucket.rb

.create(s3, name, create = false, perms = nil, headers = {}) ⇒ Object

Create a Bucket instance. If the bucket does not exist and create is set, a new bucket is created on S3. Launching this method with create=true may affect on the bucket’s ACL if the bucket already exists. Returns Bucket instance or nil if the bucket does not exist and create is not set.

s3 = Aws::S3.new(aws_access_key_id, aws_secret_access_key)
 ...
bucket1 = Aws::S3::Bucket.create(s3, 'my_awesome_bucket_1')
bucket1.keys  #=> exception here if the bucket does not exists
 ...
bucket2 = Aws::S3::Bucket.create(s3, 'my_awesome_bucket_2', true)
bucket2.keys  #=> list of keys
# create a bucket at the European location with public read access
bucket3 = Aws::S3::Bucket.create(s3,'my-awesome-bucket-3', true, 'public-read', :location => :eu)

see http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAccessPolicy.html
(section: Canned Access Policies)


27
28
29
# File 'lib/s3/bucket.rb', line 27

def self.create(s3, name, create=false, perms=nil, headers={})
  s3.bucket(name, create, perms, headers)
end