headBucket

abstract suspend fun headBucket(input: HeadBucketRequest): HeadBucketResponse

You can use this operation to determine if a bucket exists and if you have permission to access it. The action returns a 200 OK if the bucket exists and you have permission to access it.

If the bucket does not exist or you do not have permission to access it, the HEAD request returns a generic 400 Bad Request, 403 Forbidden or 404 Not Found code. A message body is not included, so you cannot determine the exception beyond these error codes.

**Directory buckets ** - You must make requests for this API operation to the Zonal endpoint. These endpoints support virtual-hosted-style requests in the format https://<i>bucket_name</i>.s3express-<i>az_id</i>.<i>region</i>.amazonaws.com. Path-style requests are not supported. For more information, see Regional and Zonal endpoints in the Amazon S3 User Guide.

Authentication and authorization

All HeadBucket requests must be authenticated and signed by using IAM credentials (access key ID and secret access key for the IAM identities). All headers with the x-amz- prefix, including x-amz-copy-source, must be signed. For more information, see REST Authentication.

Directory bucket - You must use IAM credentials to authenticate and authorize your access to the HeadBucket API operation, instead of using the temporary security credentials through the CreateSession API operation.

Amazon Web Services CLI or SDKs handles authentication and authorization on your behalf.

Permissions

HTTP Host header syntax

**Directory buckets ** - The HTTP Host header syntax is <i>Bucket_name</i>.s3express-<i>az_id</i>.<i>region</i>.amazonaws.com.

Samples


fun main() { 
   //sampleStart 
   // This operation checks to see if a bucket exists.
s3Client.headBucket {
    bucket = "acl1"
} 
   //sampleEnd
}