API | Operation | Description |
Querying object metadata | Queries the metadata of an object. |
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 "video/xxx/movie.mp4"headerRequest.object = @"exampleobject";// versionId specifies the version ID of an object to query (if versioning is enabled). If versionId is not specified, the latest version will be queried.headerRequest.versionID = @"versionID";// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketheaderRequest.bucket = @"examplebucket-1250000000";[headerRequest setFinishBlock:^(NSDictionary* result, NSError *error) {// "result" contains the request result.// Obtain the CRC64 value of the object.NSString * crc64 = [[outputObject __originHTTPURLResponse__].allHeaderFields valueForKey:@"x-cos-hash-crc64ecma"];}];[[QCloudCOSXMLService defaultCOSXML] HeadObject:headerRequest];
let headObject = QCloudHeadObjectRequest.init();// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketheadObject.bucket = "examplebucket-1250000000";// versionId specifies the version ID of an object to query (if versioning is enabled). If versionId 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 "video/xxx/movie.mp4"headObject.object = "exampleobject";headObject.finishBlock = {(result,error) inif let result = result {// Obtain the CRC64 value of the object.let crc64 = result?.__originHTTPURLResponse__.allHeaderFields["x-cos-hash-crc64ecma"];} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().headObject(headObject);
Was this page helpful?