Skip to content

Commit

Permalink
严格签名 (#342)
Browse files Browse the repository at this point in the history
* 补充文档转码参数

* 人脸特效拆分URL方式

* x-ci-*header写入签名

* ci补充参数

---------

Co-authored-by: franktguo <[email protected]>
  • Loading branch information
nic12347 and franktguo authored Jan 21, 2025
1 parent 17b973a commit 668cfbd
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 38 deletions.
6 changes: 5 additions & 1 deletion sample/CreateDataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
'DatasetName'=> 'test', // 数据集名称,同一个账户下唯一。命名规则如下: 长度为1~32字符。 只能包含小写英文字母,数字,短划线(-)。 必须以英文字母和数字开头。;是否必传:是
'Description'=> 'test', // 数据集描述信息。长度为1~256个英文或中文字符,默认值为空。;是否必传:否
'TemplateId'=> 'Official:COSBasicMeta', // 指模板,在建立元数据索引时,后端将根据模板来决定收集哪些元数据。每个模板都包含一个或多个算子,不同的算子表示不同的元数据。目前支持的模板: Official:DefaultEmptyId:默认为空的模板,表示不进行元数据的采集。 Official:COSBasicMeta:基础信息模板,包含 COS 文件基础元信息算子,表示采集 COS 文件的名称、类型、ACL等基础元信息数据。 Official:FaceSearch:人脸检索模板,包含人脸检索、COS 文件基础元信息算子。Official:ImageSearch:图像检索模板,包含图像检索、COS 文件基础元信息算子。;是否必传:否

'Version' => 'basic', // 数据集版本。basic、standard,默认为basic。
'Volume' => 0, // Version为basic时为50w。Version为standard时,默认为500w,可设置1-10000,单位w。传0采用默认值。
'TrainingMode' => 1, // 训练数据的来源模式。
'TrainingDataset' => '', // 训练数据的数据集名称。仅在TrainingMode为0时生效。
'TrainingURI' => '', // 训练数据的资源路径。仅在TrainingMode为1时生效。
));
// 请求成功
print_r($result);
Expand Down
21 changes: 18 additions & 3 deletions sample/imageFaceEffect.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
'secretId' => $secretId,
'secretKey' => $secretKey)));
try {
// 人脸特效 https://cloud.tencent.com/document/product/460/47197
$result = $cosClient->ImageFaceEffect(array(
// 人脸特效
// 桶文件
$result = $cosClient->imageFaceEffect(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'Key' => '', // ObjectKey
'Key' => 'xxx.jpg', // ObjectKey
'type' => 'face-beautify', // 人脸特效类型。人脸美颜:face-beautify;人脸性别转换:face-gender-transformation;人脸年龄变化:face-age-transformation;人像分割:face-segmentation
'whitening' => 30,
'smoothing' => 10,
Expand All @@ -26,6 +27,20 @@
'age' => 18,
));
print_r($result);

// 第三方URL
$result = $cosClient->imageUrlFaceEffect(array(
'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
'type' => 'face-beautify', // 人脸特效类型。人脸美颜:face-beautify;人脸性别转换:face-gender-transformation;人脸年龄变化:face-age-transformation;人像分割:face-segmentation
'whitening' => 30,
'smoothing' => 10,
'faceLifting' => 70,
'eyeEnlarging' => 70,
'gender' => 1,
'age' => 18,
'detectUrl' => 'https://xxx.com/xxx.jpg',
));
print_r($result);
} catch (\Exception $e) {
// 请求失败
echo($e);
Expand Down
1 change: 1 addition & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
* @method object CloseOriginProtect(array $args) 关闭原图保护
* @method object ImageDetectFace(array $args) 人脸检测
* @method object ImageFaceEffect(array $args) 人脸特效
* @method object ImageUrlFaceEffect(array $args) 人脸特效
* @method object IDCardOCR(array $args) 身份证识别
* @method object IDCardOCRByUpload(array $args) 身份证识别-上传时处理
* @method object GetLiveCode(array $args) 获取数字验证码
Expand Down
111 changes: 77 additions & 34 deletions src/Descriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static function CreateMediaTranscodeJobs() {
'Bucket' => array( 'required' => true, 'type' => 'string', 'location' => 'uri', ),
'Tag' => array( 'location' => 'xml', 'type' => 'string', ),
'QueueId' => array( 'location' => 'xml', 'type' => 'string', ),
'QueueType' => array( 'location' => 'xml', 'type' => 'string', ),
'CallBack' => array( 'location' => 'xml', 'type' => 'string', ),
'CallBackFormat' => array( 'location' => 'xml', 'type' => 'string', ),
'CallBackType' => array( 'location' => 'xml', 'type' => 'string', ),
Expand Down Expand Up @@ -271,6 +272,33 @@ public static function CreateMediaTranscodeJobs() {
'State' => array( 'type' => 'string', 'location' => 'xml', ),
),
),
'Subtitles' => array(
'type' => 'object',
'location' => 'xml',
'properties' => array(
'Subtitle' => array(
'type' => 'array',
'location' => 'xml',
'data' => array(
'xmlFlattened' => true,
),
'items' => array(
'type' => 'object',
'name' => 'Subtitle',
'sentAs' => 'Subtitle',
'properties' => array(
'Url' => array( 'type' => 'string', 'location' => 'xml', ),
'Embed' => array( 'type' => 'string', 'location' => 'xml', ),
'FontType' => array( 'type' => 'string', 'location' => 'xml', ),
'FontSize' => array( 'type' => 'string', 'location' => 'xml', ),
'FontColor' => array( 'type' => 'string', 'location' => 'xml', ),
'OutlineColor' => array( 'type' => 'string', 'location' => 'xml', ),
'VMargin' => array( 'type' => 'string', 'location' => 'xml', ),
),
),
),
),
),
),
),
'CallBackMqConfig' => array(
Expand All @@ -282,6 +310,15 @@ public static function CreateMediaTranscodeJobs() {
'MqName' => array( 'type' => 'string', 'location' => 'xml', ),
),
),
'CallBackKafkaConfig' => array(
'type' => 'object',
'location' => 'xml',
'properties' => array(
'Region' => array( 'type' => 'string', 'location' => 'xml', ),
'InstanceId' => array( 'type' => 'string', 'location' => 'xml', ),
'Topic' => array( 'type' => 'string', 'location' => 'xml', ),
),
),
),
);
}
Expand Down Expand Up @@ -2145,7 +2182,7 @@ public static function DetectVideo() {
'type' => 'object',
'properties' => array(
'Mode' => array( 'type' => 'string', 'location' => 'xml', ),
'Count' => array( 'type' => 'string', 'location' => 'xml', ),
'Count' => array( 'type' => 'integer', 'location' => 'xml', ),
'TimeInterval' => array( 'type' => 'numeric', 'location' => 'xml', ),
),
),
Expand Down Expand Up @@ -3485,39 +3522,19 @@ public static function CreateDocProcessJobs() {
'type' => 'object',
'location' => 'xml',
'properties' => array(
'SrcType' => array(
'type' => 'string',
),
'TgtType' => array(
'type' => 'string',
),
'SheetId' => array(
'type' => 'integer',
),
'StartPage' => array(
'type' => 'integer',
),
'EndPage' => array(
'type' => 'integer',
),
'ImageParams' => array(
'type' => 'string',
),
'DocPassword' => array(
'type' => 'string',
),
'Comments' => array(
'type' => 'integer',
),
'PaperDirection' => array(
'type' => 'integer',
),
'Quality' => array(
'type' => 'integer',
),
'Zoom' => array(
'type' => 'integer',
),
'SrcType' => array( 'type' => 'string', 'location' => 'xml', ),
'TgtType' => array( 'type' => 'string', 'location' => 'xml', ),
'StartPage' => array( 'type' => 'integer', 'location' => 'xml', ),
'EndPage' => array( 'type' => 'integer', 'location' => 'xml', ),
'SheetId' => array( 'type' => 'integer', 'location' => 'xml', ),
'PaperDirection' => array( 'type' => 'integer', 'location' => 'xml', ),
'PaperSize' => array( 'type' => 'integer', 'location' => 'xml', ),
'ImageParams' => array( 'type' => 'string', 'location' => 'xml', ),
'Quality' => array( 'type' => 'integer', 'location' => 'xml', ),
'Zoom' => array( 'type' => 'integer', 'location' => 'xml', ),
'ImageDpi' => array( 'type' => 'integer', 'location' => 'xml', ),
'DocPassword' => array( 'type' => 'string', 'location' => 'xml', ),
'Comments' => array( 'type' => 'integer', 'location' => 'xml', ),
),
),
),
Expand Down Expand Up @@ -12927,6 +12944,27 @@ public static function ImageFaceEffect() {
),
);
}

public static function ImageUrlFaceEffect() {
return array(
'httpMethod' => 'GET',
'uri' => '/{Bucket}?ci-process=face-effect',
'class' => 'Qcloud\\Cos\\Command',
'responseClass' => 'ImageFaceEffectOutput',
'responseType' => 'model',
'parameters' => array(
'Bucket' => array( 'required' => true, 'type' => 'string', 'location' => 'uri', ),
'type' => array( 'type' => 'string', 'location' => 'query', ),
'whitening' => array( 'type' => 'integer', 'location' => 'query', ),
'smoothing' => array( 'type' => 'integer', 'location' => 'query', ),
'faceLifting' => array( 'type' => 'integer', 'location' => 'query', ),
'eyeEnlarging' => array( 'type' => 'integer', 'location' => 'query', ),
'gender' => array( 'type' => 'integer', 'location' => 'query', ),
'age' => array( 'type' => 'integer', 'location' => 'query', ),
'detectUrl' => array('type' => 'string', 'location' => 'query', 'sentAs' => 'detect-url'),
),
);
}
public static function ImageFaceEffectOutput() {
return array(
'type' => 'object',
Expand Down Expand Up @@ -19289,6 +19327,11 @@ public static function CreateDataset() {
'DatasetName' => array( 'location' => 'json', 'type' => 'string', ),
'Description' => array( 'location' => 'json', 'type' => 'string', ),
'TemplateId' => array( 'location' => 'json', 'type' => 'string', ),
'Version' => array( 'location' => 'json', 'type' => 'string', ),
'Volume' => array( 'location' => 'json', 'type' => 'integer', ),
'TrainingMode' => array( 'location' => 'json', 'type' => 'integer', ),
'TrainingDataset' => array( 'location' => 'json', 'type' => 'string', ),
'TrainingURI' => array( 'location' => 'json', 'type' => 'string', ),
),

);
Expand Down
1 change: 1 addition & 0 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -3787,6 +3787,7 @@ public static function getService() {
'CloseOriginProtect' => Descriptions::CloseOriginProtect(), // 关闭原图保护
'ImageDetectFace' => Descriptions::ImageDetectFace(), // 人脸检测
'ImageFaceEffect' => Descriptions::ImageFaceEffect(), // 人脸特效
'ImageUrlFaceEffect' => Descriptions::ImageUrlFaceEffect(), // 人脸特效
'IDCardOCR' => Descriptions::IDCardOCR(), // 身份证识别
'IDCardOCRByUpload' => Descriptions::IDCardOCRByUpload(), // 身份证识别-上传时处理
'GetLiveCode' => Descriptions::GetLiveCode(), // 获取数字验证码
Expand Down
3 changes: 3 additions & 0 deletions src/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function needCheckHeader( $header ) {
if ( startWith( $header, 'x-cos-' ) ) {
return true;
}
if ( startWith( $header, 'x-ci-' ) ) {
return true;
}
if ( in_array( $header, $this->signHeader ) ) {
return true;
}
Expand Down

0 comments on commit 668cfbd

Please sign in to comment.