createContainer method

Future<CreateContainerOutput> createContainer({
  1. required String containerName,
  2. List<Tag>? tags,
})

Creates a storage container to hold objects. A container is similar to a bucket in the Amazon S3 service.

May throw ContainerInUseException. May throw LimitExceededException. May throw InternalServerError.

Parameter containerName : The name for the container. The name must be from 1 to 255 characters. Container names must be unique to your AWS account within a specific region. As an example, you could create a container named movies in every region, as long as you don’t have an existing container with that name.

Parameter tags : An array of key:value pairs that you define. These values can be anything that you want. Typically, the tag key represents a category (such as "environment") and the tag value represents a specific value within that category (such as "test," "development," or "production"). You can add up to 50 tags to each container. For more information about tagging, including naming and usage conventions, see Tagging Resources in MediaStore.

Implementation

Future<CreateContainerOutput> createContainer({
  required String containerName,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(containerName, 'containerName');
  _s.validateStringLength(
    'containerName',
    containerName,
    1,
    255,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'MediaStore_20170901.CreateContainer'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ContainerName': containerName,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateContainerOutput.fromJson(jsonResponse.body);
}