This document provides an overview of APIs and SDK code samples related to querying object metadata.
API | Operation Name | Description |
---|---|---|
HEAD Object | Querying object metadata | Queries the metadata of an object |
For the parameters and method descriptions of all the APIs in the SDK, please see SDK API Reference.
This API is used to query the metadata of an object.
Objective-C
QCloudHeadObjectRequest* headerRequest = [QCloudHeadObjectRequest new];
// Object key, i.e. the full path of a COS object. If the object is in a directory, the path should be "dir1/object1"
headerRequest.object = @"exampleobject";
// Specify the `versionId` of the object if versioning is enabled; if this parameter is not specified, the latest version will be queried
headerRequest.versionID = @"versionID";
// Bucket name in the format: `BucketName-APPID`
headerRequest.bucket = @"examplebucket-1250000000";
[headerRequest setFinishBlock:^(NSDictionary* result, NSError *error) {
// `result` contains the request result
}];
[[QCloudCOSXMLService defaultCOSXML] HeadObject:headerRequest];
Note:
For more samples, please visit GitHub.
Swift
let headObject = QCloudHeadObjectRequest.init();
// Bucket name in the format: `BucketName-APPID`
headObject.bucket = "examplebucket-1250000000";
// Specify the `versionId` of the object if versioning is enabled; if this parameter is not specified, the latest version will be queried
headObject.versionID = "versionID";
// Object key, i.e. the full path of a COS object. If the object is in a directory, the path should be "dir1/object1"
headObject.object = "exampleobject";
headObject.finishBlock = {(result,error) in
if let result = result {
// "result" contains response headers
} else {
print(error!);
}
}
QCloudCOSXMLService.defaultCOSXML().headObject(headObject);
Note:
For more samples, please visit GitHub.
Was this page helpful?