Creates an Amazon S3 bucket.
Every object stored in Amazon S3 is contained in a bucket. Buckets partition the namespace of objects stored in Amazon S3 at the top level. in a bucket, any name can be used for objects. However, bucket names must be unique across all of Amazon S3.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The name of the bucket to create. |
|
|
Required |
The preferred geographical location for the bucket. [Allowed values: |
|
|
Optional |
The ACL settings for the specified object. Accepts any of the following constants: [Allowed values: |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Create a new bucket, setting the storage region.
// Instantiate the class $s3 = new AmazonS3(); $bucket = 'my-bucket' . strtolower($s3->key); $response = $s3->create_bucket($bucket, AmazonS3::REGION_US_STANDARD); // Success? var_dump($response->isOK());Result:
bool(true)
Create a new bucket, setting the storage region and ACL settings.
// Instantiate the class $s3 = new AmazonS3(); $bucket = 'my-bucket-us-east-acl' . strtolower($s3->key); $response = $s3->create_bucket($bucket, AmazonS3::REGION_US_STANDARD, AmazonS3::ACL_PUBLIC); // Success? var_dump($response->isOK());Result:
bool(true)
Create a new bucket, setting the storage region and using Grants for permissions.
// Instantiate the class $s3 = new AmazonS3(); $bucket = 'my-bucket' . strtolower($s3->key); $response = $s3->create_bucket($bucket, AmazonS3::REGION_US_STANDARD, array( array( 'id' => AmazonS3::USERS_AUTH, 'permission' => AmazonS3::GRANT_READ ), array( 'id' => AmazonS3::USERS_AUTH, 'permission' => AmazonS3::GRANT_WRITE ), array( 'id' => AmazonS3::USERS_ALL, 'permission' => AmazonS3::GRANT_WRITE ), array( 'id' => 'my-email-address@domain.com', 'permission' => AmazonS3::GRANT_FULL_CONTROL), array( 'id' => '41f37e4803dbae41aa52290608a037dcf2309199b81c6257fe5570098b9e55a9', 'permission' => AmazonS3::GRANT_WRITE ), )); // Success? var_dump($response->isOK());Result:
bool(true)
See Also
Source
Method defined in services/s3.class.php | Toggle source view (67 lines) | View on GitHub