HCP Tenant Management Help


Checking the existence of an object or folder

You use the HTTP HEAD method to check the existence of an object or folder in a bucket. To check the existence of an object, you need read permission for the bucket containing the object or for the object itself. To check the existence of a folder, you need read permission for the bucket.

In response to a request to check the existence of an object or folder, HCP returns a 200 (OK) status code if the object or folder exists and a 404 (Not Found) status code if the object or folder doesn’t exist. If you don’t have read permission for the bucket or object, HCP returns a 403 (Forbidden) status code.

Checking the existence of an object version

By default, a HEAD request to check the existence of an object checks the existence of the current version of the object. However, while versioning is enabled for the target bucket, you can use the versionId query parameter to check the existence of a specific version of an object.

If the version identified by the versionId parameter does not exist, HCP returns a 404 (Not Found) status code. If the version identified by the versionId parameter is a delete marker, HCP returns a 200 (OK) status code.

Valid values for the versionId parameter are integers greater than or equal to zero. Normally, the value is the version ID of a version of the object specified in the request.

The versionId query parameter is not case sensitive.

If you include the versionId parameter in a HEAD request while versioning is disabled, the parameter is ignored.

For information about object versions, see Versioning. For information about delete markers, see Deleting an object or folder.

Object information

If the status code returned in response to a request to check the existence of an object, object version, or folder is 200 (OK), the response headers include this information:

The ETag for the specified item (ETag header). For information about ETags, see Storing an object.

While versioning is enabled for the target bucket, the version ID of the specified item (x-amz-version-id header).

The date the specified item was last modified (Last-Modified header).

The Internet media type of the specified item (Content-Type header).

The size of the specified item, in bytes (Content-Length header).

For an object or object version, any custom metadata stored in the .metapairs annotation for that item (x-amz-meta- headers). For information about x-amz-meta- headers, see Custom metadata.

Conditionally checking the existence of an object, object version, or folder

You can use the If-Match, If-None-Match, If-Modified-Since, and If-Unmodified-Since request headers to make HEAD requests conditional:

The If-Match and If-None-Match headers compare the ETag for the specified item to one or more values that you specify. Typically, each value is the ETag for an object or object version of interest.

The If-Modified-Since and If-Unmodified-Since headers compare the date and time the specified item was last modified to a date and time that you specify. The comparison is at the level of seconds, so you cannot use these headers to differentiate between changes that happened at different milliseconds within the same second.

If the specified item meets all the conditions specified by the conditional headers included in the request, HCP returns a 200 (OK) status code. If the specified item does not meet the condition specified by:

An If-Match or If-Unmodified-Since header, HCP returns a 412 (Precondition Failed) status code

An If-None-Match or If-Modified-Since header, HCP returns a 304 (Not Modified) status code

If a request includes multiple different conditional headers, HCP processes any If-Match and If-None-Match headers before any If-Modified-Since or If-Unmodified-Since headers. If a request includes more than one of any given header, HCP processes only the first one of those headers and ignores the others.

© 2015, 2019 Hitachi Vantara Corporation. All rights reserved.