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 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.
// This operation checks to see if a bucket exists. constinput = { "Bucket":"acl1" }; constcommand = newHeadBucketCommand(input); awaitclient.send(command); // example id: to-determine-if-bucket-exists-1473110292262
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 generic404 Not Found
or403 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.
See
input
shape.response
shape.config
shape.Throws
NotFound (client fault)
The specified content does not exist.
Example
To determine if bucket exists