Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HeadBucketCommand

This action is useful to determine if a bucket exists and 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 404 Not Found or 403 Forbidden code. A message body is not included, so you cannot determine the exception beyond these error codes.

To use this operation, you must have permissions to perform the s3:ListBucket action. The bucket owner has this permission by default and can grant this permission to others. For more information about permissions, see Permissions Related to Bucket Subresource Operations and Managing Access Permissions to Your Amazon S3 Resources.

To use this API against an access point, you must provide the alias of the access point in place of the bucket name or specify the access point ARN. When using the access point ARN, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using the Amazon Web Services SDKs, you provide the ARN in place of the bucket name. For more information see, Using access points.

example

Use a bare-bones client and the command you need to make an API call.

import { S3Client, HeadBucketCommand } from "@aws-sdk/client-s3"; // ES Modules import
// const { S3Client, HeadBucketCommand } = require("@aws-sdk/client-s3"); // CommonJS import
const client = new S3Client(config);
const command = new HeadBucketCommand(input);
const response = await client.send(command);
see

HeadBucketCommandInput for command's input shape.

see

HeadBucketCommandOutput for command's response shape.

see

config for S3Client's config shape.

Hierarchy

Implements

Index

Constructors

Properties

Constructors

constructor

  • Parameters

    Returns HeadBucketCommand

  • Parameters

    • input: HeadBucketCommandInput

    Returns HeadBucketCommand

Properties

Readonly input

input: HeadBucketCommandInput

Readonly middlewareStack

middlewareStack: IMiddlewareStack<HeadBucketCommandInput, HeadBucketCommandOutput>