createBucket method
- required String bucket,
- BucketCannedACL? acl,
- CreateBucketConfiguration? createBucketConfiguration,
- String? grantFullControl,
- String? grantRead,
- String? grantReadACP,
- String? grantWrite,
- String? grantWriteACP,
- bool? objectLockEnabledForBucket,
- String? outpostId,
Not every string is an acceptable bucket name. For information on bucket naming restrictions, see Working with Amazon S3 Buckets.
S3 on Outposts buckets do not support
- ACLs. Instead, configure access point policies to manage access to buckets.
- Public access.
- Object Lock
- Bucket Location constraint
x-amz-outpost-id
in your API request, see the Examples
section.
The following actions are related to CreateBucket
for Amazon
S3 on Outposts:
May throw BucketAlreadyExists. May throw BucketAlreadyOwnedByYou.
Parameter bucket
:
The name of the bucket.
Parameter acl
:
The canned ACL to apply to the bucket.
Parameter createBucketConfiguration
:
The configuration information for the bucket.
Parameter grantFullControl
:
Allows grantee the read, write, read ACP, and write ACP permissions on the
bucket.
Parameter grantRead
:
Allows grantee to list the objects in the bucket.
Parameter grantReadACP
:
Allows grantee to read the bucket ACL.
Parameter grantWrite
:
Allows grantee to create, overwrite, and delete any object in the bucket.
Parameter grantWriteACP
:
Allows grantee to write the ACL for the applicable bucket.
Parameter objectLockEnabledForBucket
:
Specifies whether you want S3 Object Lock to be enabled for the new
bucket.
Parameter outpostId
:
The ID of the Outposts where the bucket is being created.
Implementation
Future<CreateBucketResult> createBucket({
required String bucket,
BucketCannedACL? acl,
CreateBucketConfiguration? createBucketConfiguration,
String? grantFullControl,
String? grantRead,
String? grantReadACP,
String? grantWrite,
String? grantWriteACP,
bool? objectLockEnabledForBucket,
String? outpostId,
}) async {
ArgumentError.checkNotNull(bucket, 'bucket');
_s.validateStringLength(
'bucket',
bucket,
3,
255,
isRequired: true,
);
_s.validateStringLength(
'outpostId',
outpostId,
1,
64,
);
final headers = <String, String>{
if (acl != null) 'x-amz-acl': acl.toValue(),
if (grantFullControl != null)
'x-amz-grant-full-control': grantFullControl.toString(),
if (grantRead != null) 'x-amz-grant-read': grantRead.toString(),
if (grantReadACP != null) 'x-amz-grant-read-acp': grantReadACP.toString(),
if (grantWrite != null) 'x-amz-grant-write': grantWrite.toString(),
if (grantWriteACP != null)
'x-amz-grant-write-acp': grantWriteACP.toString(),
if (objectLockEnabledForBucket != null)
'x-amz-bucket-object-lock-enabled':
objectLockEnabledForBucket.toString(),
if (outpostId != null) 'x-amz-outpost-id': outpostId.toString(),
};
final $result = await _protocol.sendRaw(
method: 'PUT',
requestUri: '/v20180820/bucket/${Uri.encodeComponent(bucket)}',
headers: headers,
payload: createBucketConfiguration?.toXml('CreateBucketConfiguration'),
exceptionFnMap: _exceptionFns,
);
final $elem = await _s.xmlFromResponse($result);
return CreateBucketResult(
bucketArn: _s.extractXmlStringValue($elem, 'BucketArn'),
location: _s.extractHeaderStringValue($result.headers, 'Location'),
);
}