Feature Overview
This document provides an overview of APIs and SDK code samples for querying object metadata.
API | Operation | Description |
Querying object metadata | Queries the metadata of an object |
Querying object metadata
Note
This API is used to query the metadata of an object.
Use Cases
cos.headObject({Bucket: 'examplebucket-1250000000', /* Enter your own bucket, required field */Region: 'COS_REGION', /* Required field specifying the region where the bucket is located, e.g., ap-beijing */Key: '1.jpg', /* The object key stored in the bucket (e.g., 1.jpg, a/b/test.txt), required field */}, function(err, data) {console.log(err || data);});
Description
Parameter | ParameterDescription | Local Disk Types | Required |
Bucket | Bucket name in the format of BucketName-APPID. | String | Required |
Region | String | Required | |
Key | Object key (object name), the unique identifier of an object in a bucket. For more information, see Object Overview. | String | Required |
IfModifiedSince | Returns object metadata if the object is modified after the specified time; otherwise, 304 is returned | String | Not required |
Callback function description
function(err, data) { ... }
Parameter | ParameterDescription | Local Disk Types |
err | Error code, which is returned when an error (network error or service error) occurs. If the request is successful, this parameter is empty. For more information, see Error Codes. | Object |
- statusCode | HTTP status code, such as 200, 403, and 404 | Number |
- headers | Returned headers | Object |
data | Object returned when the request is successful. If the request fails, this parameter is empty. | Object |
- statusCode | HTTP status code returned by the request, such as 200 and 304. If no modification is made after the specified time, 304 will be returned. | Number |
- headers | Returned headers | Object |
- x-cos-object-type | Indicates whether an object is appendable. Enumerated values: normal, appendable. The default value normal is not displayed if returned | String |
- x-cos-storage-class | The storage class of the object, with enumeration values: STANDARD, STANDARD_IA, ARCHIVE, DEEP_ARCHIVE, etc. The default value is STANDARD and is not displayed in the response. For more information on storage classes, see Storage Class Overview. | String |
- x-cos-meta-* | User-defined metadata | String |
- NotModified | Indicates whether an object is unmodified after the specified time. | Boolean |
- ETag | Returns the MD5 checksum value of the file. The ETag value can be used to verify whether the object has been damaged during the upload process. For example, "09cba091df696af91549de27b8e7d0f6", Note: The ETag value here is enclosed in double quotes | String |
- VersionId | Returns the version ID for versioning-enabled buckets. For buckets which have never had versioning enabled, this parameter is not returned | String |