有奖捉虫:办公协同&微信生态&物联网文档专题 HOT

简介

本文档提供关于查询对象元数据操作相关的 API 概览以及 SDK 示例代码。
API
操作名
操作描述
查询对象元数据
查询对象的元数据信息

查询对象元数据

功能说明

查询 Object 的 Meta 信息(HEAD Object)。

方法原型

public Guzzle\\Service\\Resource\\Model headObject(array $args = array());

请求示例

<?php

require dirname(__FILE__) . '/../vendor/autoload.php';

$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\\Cos\\Client(
array(
'region' => $region,
'scheme' => 'https', //协议头部,默认为http
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));

try {
$result = $cosClient->headObject(array(
'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => 'exampleobject',
));
// 请求成功
print_r($result);
} catch (\\Exception $e) {
// 请求失败
echo($e);
}

参数说明

参数名称
类型
描述
是否必填
Bucket
String
存储桶名称,格式:BucketName-APPID
Key
String
此处的 Key 为对象键,对象键是对象在存储桶中的唯一标识。例如,在对象的访问域名
examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/doc/pic.jpg 中,对象键为doc/pic.jpg
VersionId
String
开启版本控制后,指定文件的具体版本

返回结果示例

Guzzle\\Service\\Resource\\Model Object
(
[structure:protected] =>
[data:protected] => Array
(
[DeleteMarker] =>
[AcceptRanges] =>
[Expiration] =>
[Restore] =>
[LastModified] => Tue, 02 Apr 2019 12:38:09 GMT
[ContentLength] => 238186
[ETag] => "af9f3b8eaf64473278909183abba1e31"
[MissingMeta] =>
[VersionId] =>
[CacheControl] =>
[ContentDisposition] =>
[ContentEncoding] =>
[ContentLanguage] =>
[ContentType] => text/plain; charset=utf-8
[Expires] =>
[ServerSideEncryption] =>
[Metadata] => Array
(
[md5] => af9f3b8eaf64473278909183abba1e31
)
[SSECustomerAlgorithm] =>
[SSECustomerKeyMD5] =>
[SSEKMSKeyId] =>
[StorageClass] =>
[RequestCharged] =>
[ReplicationStatus] =>
[RequestId] => NWNhMzU3Y2ZfMzFhYzM1MGFfODdhMF8xOTExM2U=
[CRC] => 16749565679157681890
)

)

返回结果说明

参数名称
类型
描述
父节点
CacheControl
String
缓存策略,设置 Cache-Control
ContentDisposition
String
文件名称,设置 Content-Disposition
ContentEncoding
String
编码格式,设置 Content-Encoding
ContentLanguage
String
语言类型,设置 Content-Language
ContentLength
Int
设置传输长度
ContentType
String
内容类型,设置 Content-Type
Metadata
Array
用户自定义的文件元信息
StorageClass
String
文件的存储类型,例如 STANDARD、STANDARD_IA、ARCHIVE。更多存储类型请参见 存储类型概述
ServerSideEncryption
String
服务端加密方法
ETag
String
文件的 MD5 值
Restore
String
归档文件的回热信息
CRC
String
CRC64 检验码来进行 数据校验