Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions sample/deleteObjectTagging.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

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

$secretId = "COS_SECRETID"; //"云 API 密钥 SecretId";
$secretKey = "COS_SECRETKEY"; //"云 API 密钥 SecretKey";
$region = "ap-beijing"; //设置一个默认的存储桶地域
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https', //协议头部,默认为http
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));
try {
$result = $cosClient->deleteObjectTagging(array(
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
'Key' => 'exampleobject',
));
// 请求成功
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}
25 changes: 25 additions & 0 deletions sample/getObjectTagging.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
require dirname(__FILE__) . '/../vendor/autoload.php';

$secretId = "COS_SECRETID"; //"云 API 密钥 SecretId";
$secretKey = "COS_SECRETKEY"; //"云 API 密钥 SecretKey";
$region = "ap-beijing"; //设置一个默认的存储桶地域
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https', //协议头部,默认为http
'credentials' => array(
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
$result = $cosClient->getObjectTagging(array(
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
'Key' => 'exampleobject'
));
// 请求成功
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
}

33 changes: 33 additions & 0 deletions sample/putObjectTagging.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

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

$secretId = "COS_SECRETID"; //"云 API 密钥 SecretId";
$secretKey = "COS_SECRETKEY"; //"云 API 密钥 SecretKey";
$region = "ap-beijing"; //设置一个默认的存储桶地域
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https', //协议头部,默认为http
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));
try {
$result = $cosClient->putObjectTagging(array(
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
'Key' => 'exampleobject',
'TagSet' => array(
array('Key'=>'key1',
'Value'=>'value1',
),
array('Key'=>'key2',
'Value'=>'value2',
),
),
));
// 请求成功
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo "$e\n";
}
151 changes: 149 additions & 2 deletions src/Qcloud/Cos/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,104 @@ public static function getService() {
),
),
),
// 配置对象标签的方法.
'PutObjectTagging' => array(
'httpMethod' => 'PUT',
'uri' => '/{Bucket}{/Key*}?tagging',
'class' => 'Qcloud\\Cos\\Command',
'responseClass' => 'PutObjectTaggingOutput',
'responseType' => 'model',
'data' => array(
'xmlRoot' => array(
'name' => 'Tagging',
),
'contentMd5' => true,
),
'parameters' => array(
'Bucket' => array(
'required' => true,
'type' => 'string',
'location' => 'uri',
),
'Key' => array(
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey'
)
),
'TagSet' => array(
'required' => true,
'type' => 'array',
'location' => 'xml',
'items' => array(
'name' => 'TagRule',
'type' => 'object',
'sentAs' => 'Tag',
'properties' => array(
'Key' => array(
'required' => true,
'type' => 'string',
),
'Value' => array(
'required' => true,
'type' => 'string',
),
),
),
),
),
),
// 获取对象标签信息的方法
'GetObjectTagging' => array(
'httpMethod' => 'GET',
'uri' => '/{Bucket}{/Key*}?tagging',
'class' => 'Qcloud\\Cos\\Command',
'responseClass' => 'GetObjectTaggingOutput',
'responseType' => 'model',
'parameters' => array(
'Bucket' => array(
'required' => true,
'type' => 'string',
'location' => 'uri',
),
'Key' => array(
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey'
)
)
),
),
// 删除对象标签的方法
'DeleteObjectTagging' => array(
'httpMethod' => 'DELETE',
'uri' => '/{Bucket}{/Key*}?tagging',
'class' => 'Qcloud\\Cos\\Command',
'responseClass' => 'DeleteObjectTaggingOutput',
'responseType' => 'model',
'parameters' => array(
'Bucket' => array(
'required' => true,
'type' => 'string',
'location' => 'uri'
),
'Key' => array(
'required' => true,
'type' => 'string',
'location' => 'uri',
'minLength' => 1,
'filters' => array(
'Qcloud\\Cos\\Client::explodeKey'
)
)
)
),
// 下载对象的方法.
'GetObject' => array(
'httpMethod' => 'GET',
Expand Down Expand Up @@ -1019,7 +1117,7 @@ public static function getService() {
),
'ContentMD5' => array(
'type' => array(
'string',
// 'string',
'boolean'
),
'location' => 'header',
Expand Down Expand Up @@ -1134,7 +1232,7 @@ public static function getService() {
),
'ContentMD5' => array(
'type' => array(
'string',
// 'string',
'boolean'
),
'location' => 'header',
Expand Down Expand Up @@ -3550,6 +3648,55 @@ public static function getService() {
),
),
),
//设置对象标签
'PutObjectTaggingOutput' => array(
'type' => 'object',
'additionalProperties' => true,
'properties' => array(
'RequestId' => array(
'location' => 'header',
'sentAs' => 'x-cos-request-id',
),
),
),
//查询对象标签
'GetObjectTaggingOutput' => array(
'type' => 'object',
'additionalProperties' => true,
'properties' => array(
'TagSet' => array(
'type' => 'array',
'location' => 'xml',
'items' => array(
'sentAs' => 'Tag',
'type' => 'object',
'properties' => array(
'Key' => array(
'type' => 'string',
),
'Value' => array(
'type' => 'string',
),
),
),
),
'RequestId' => array(
'location' => 'header',
'sentAs' => 'x-cos-request-id',
),
),
),
//删除对象标签
'DeleteObjectTaggingOutput' => array(
'type' => 'object',
'additionalProperties' => true,
'properties' => array(
'RequestId' => array(
'location' => 'header',
'sentAs' => 'x-cos-request-id'
)
)
),
'GetObjectOutput' => array(
'type' => 'object',
'additionalProperties' => true,
Expand Down
Loading