< Previous | Contents | Next >

Checking the existence of an object or folder

You use the HTTP HEAD method to check the existence of an objector 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.


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 or is a deleted version, HCP returns a 404 (Not Found) status code.


 

Object informationConditionally checking the existence of an object, object version, or folderRequest headersResponse headersHTTP status codesExamplesExample 1: Checking the existence of an objectExample 2: Retrieving custom metadata for an object versionExample 3: Checking whether an object has been modifiedExample 4: Checking the existence of a folder