diff --git a/.gitattributes b/.gitattributes index b43f9d90..8f417106 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,4 @@ /.gitattributes export-ignore /.gitignore export-ignore /.travis.yml export-ignore -/phpunit.xml export-ignore -/src/Qcloud/Cos/Tests export-ignore /bin export-ignore diff --git a/.github/workflows/php5.6.yml b/.github/workflows/php5.6.yml new file mode 100644 index 00000000..3c3e4cff --- /dev/null +++ b/.github/workflows/php5.6.yml @@ -0,0 +1,34 @@ +name: PHP 5.6 +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + COS_REGION: ${{ secrets.COS_REGION }} + COS_APPID: ${{ secrets.COS_APPID }} + COS_SECRET: ${{ secrets.COS_SECRET }} + COS_KEY: ${{ secrets.COS_KEY }} + COS_BUCKET: ${{ secrets.COS_BUCKET }} +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: + image: php:5.6 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + run: | + apt update + apt install -y libzip-dev unzip + docker-php-ext-install zip + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + composer install + - name: Test + run: for i in `ls src/Qcloud/Cos/*.php`; do php -l $i; done \ No newline at end of file diff --git a/.github/workflows/php7.1.yml b/.github/workflows/php7.1.yml new file mode 100644 index 00000000..17bf44c8 --- /dev/null +++ b/.github/workflows/php7.1.yml @@ -0,0 +1,36 @@ +name: PHP 7.1 +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + COS_REGION: ${{ secrets.COS_REGION }} + COS_APPID: ${{ secrets.COS_APPID }} + COS_SECRET: ${{ secrets.COS_SECRET }} + COS_KEY: ${{ secrets.COS_KEY }} + COS_BUCKET: ${{ secrets.COS_BUCKET }} +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: + image: php:7.1 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Test + run: | + apt update + apt install -y libzip-dev unzip + docker-php-ext-install zip + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + composer install + composer require --dev phpunit/phpunit + ./vendor/bin/phpunit + - name: codecov + uses: codecov/codecov-action@v2 diff --git a/.github/workflows/php7.2.yml b/.github/workflows/php7.2.yml new file mode 100644 index 00000000..ce76ab1f --- /dev/null +++ b/.github/workflows/php7.2.yml @@ -0,0 +1,38 @@ +name: PHP 7.2 +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + COS_REGION: ${{ secrets.COS_REGION }} + COS_APPID: ${{ secrets.COS_APPID }} + COS_SECRET: ${{ secrets.COS_SECRET }} + COS_KEY: ${{ secrets.COS_KEY }} + COS_BUCKET: ${{ secrets.COS_BUCKET }} +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: + image: php:7.2 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Test + run: | + apt update + apt install -y libzip-dev unzip + docker-php-ext-install zip + pecl install xdebug + docker-php-ext-enable xdebug + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + composer install + composer require --dev phpunit/phpunit + XDEBUG_MODE=coverage ./vendor/bin/phpunit + - name: codecov + uses: codecov/codecov-action@v2 diff --git a/.github/workflows/php7.3.yml b/.github/workflows/php7.3.yml new file mode 100644 index 00000000..ad47d891 --- /dev/null +++ b/.github/workflows/php7.3.yml @@ -0,0 +1,38 @@ +name: PHP 7.3 +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + COS_REGION: ${{ secrets.COS_REGION }} + COS_APPID: ${{ secrets.COS_APPID }} + COS_SECRET: ${{ secrets.COS_SECRET }} + COS_KEY: ${{ secrets.COS_KEY }} + COS_BUCKET: ${{ secrets.COS_BUCKET }} +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: + image: php:7.3 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Test + run: | + apt update + apt install -y libzip-dev unzip + docker-php-ext-install zip + pecl install xdebug + docker-php-ext-enable xdebug + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + composer install + composer require --dev phpunit/phpunit + XDEBUG_MODE=coverage ./vendor/bin/phpunit + - name: codecov + uses: codecov/codecov-action@v2 diff --git a/.github/workflows/php7.4.yml b/.github/workflows/php7.4.yml new file mode 100644 index 00000000..f7337fc3 --- /dev/null +++ b/.github/workflows/php7.4.yml @@ -0,0 +1,37 @@ +name: PHP 7.4 +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + COS_REGION: ${{ secrets.COS_REGION }} + COS_APPID: ${{ secrets.COS_APPID }} + COS_SECRET: ${{ secrets.COS_SECRET }} + COS_KEY: ${{ secrets.COS_KEY }} + COS_BUCKET: ${{ secrets.COS_BUCKET }} +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: + image: php:7.4 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + run: | + apt update + apt install -y libzip-dev unzip + docker-php-ext-install zip + pecl install xdebug + docker-php-ext-enable xdebug + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + composer require --dev phpunit/phpunit + - name: Test + run: | + XDEBUG_MODE=coverage ./vendor/bin/phpunit \ No newline at end of file diff --git a/.github/workflows/php8.0.yml b/.github/workflows/php8.0.yml new file mode 100644 index 00000000..6acfa112 --- /dev/null +++ b/.github/workflows/php8.0.yml @@ -0,0 +1,39 @@ +name: PHP 8.0 +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + COS_REGION: ${{ secrets.COS_REGION }} + COS_APPID: ${{ secrets.COS_APPID }} + COS_SECRET: ${{ secrets.COS_SECRET }} + COS_KEY: ${{ secrets.COS_KEY }} + COS_BUCKET: ${{ secrets.COS_BUCKET }} +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: + image: php:8.0 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + run: | + apt update + apt install -y libzip-dev unzip + docker-php-ext-install zip + pecl install xdebug + docker-php-ext-enable xdebug + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + composer require --dev phpunit/phpunit + - name: Test + run: | + XDEBUG_MODE=coverage ./vendor/bin/phpunit + - name: codecov + uses: codecov/codecov-action@v2 diff --git a/.gitignore b/.gitignore index b042685e..762d57b2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ composer.lock vendor/ *.DS_Store index.php +clover.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index dda8559b..c227dcb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ cos-php-sdk-v5 Upgrade Guide ==================== + +2.3.1 to 2.3.2 +--------- +- 新增视频截帧,视频信息查询示例 +- 新增PUT/GET Bucket Referer示例 +- 对于相应接口添加CRC返回信息 +- 修复图片审核中ci-process param出现两次的问题 +- 修复PHP5.6 版本的依赖问题 +- 根据PHP版本自动composer install guzzle6.x或guzzle7 + +2.3.0 to 2.3.1 +--------- +- 修复文本检测的返回格式 +- 修复sample中的问题 +- 新增视频、文本、文档、音频检测 +- 新增媒体转码、截图、拼接 + 2.2.3 to 2.3.0 --------- - 新增图片审核,视频审核,音频审核,文本审核,文档审核接口 diff --git a/bin/release b/bin/release index 9ae9c2cc..00a0cdc6 100755 --- a/bin/release +++ b/bin/release @@ -6,7 +6,7 @@ * Usage: php bin/release or php bin/release version */ -require_once 'vendor/autoload.php'; +require_once '../vendor/autoload.php'; use Qcloud\Cos\Client; use Qcloud\Cos\Service; diff --git a/composer.json b/composer.json index 76aea875..4562cea0 100644 --- a/composer.json +++ b/composer.json @@ -26,8 +26,12 @@ "files": ["src/Qcloud/Cos/Common.php"] }, "require": { - "php": ">=5.3.0", - "guzzlehttp/guzzle": "~6.3", - "guzzlehttp/guzzle-services": "~1.1" + "php": ">=5.6", + "guzzlehttp/guzzle": ">=6.2.1", + "guzzlehttp/guzzle-services": ">=1.1", + "guzzlehttp/psr7": "<2.0" + }, + "config": { + "platform-check": false } } diff --git a/sample/copy.php b/sample/copy.php index 6ba9a896..2264ce72 100644 --- a/sample/copy.php +++ b/sample/copy.php @@ -17,7 +17,7 @@ $result = $cosClient->copy( $bucket = 'examplebucket-125000000', //格式:BucketName-APPID $key = 'exampleobject', - $copySorce = array( + $copySource = array( 'Region' => '', 'Bucket' => '', 'Key' => '', diff --git a/sample/getBucketReferer.php b/sample/getBucketReferer.php new file mode 100644 index 00000000..79aec974 --- /dev/null +++ b/sample/getBucketReferer.php @@ -0,0 +1,25 @@ + $region, + 'schema' => 'https', //协议头部,默认为http + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + $result = $cosClient->getBucketReferer(array( + 'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID + ) + ); + // 请求成功 + echo($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/sample/getMediaInfo.php b/sample/getMediaInfo.php new file mode 100644 index 00000000..3a7cc9d9 --- /dev/null +++ b/sample/getMediaInfo.php @@ -0,0 +1,29 @@ + $region, + 'schema' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId , + 'secretKey' => $secretKey))); + +try { + $result = $cosClient->GetMediaInfo( + array( + 'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID + 'Key' =>'exampleobject', //桶中的媒体文件,如test.mp4 + 'ci-process' => 'videoinfo' //操作类型,固定使用 videoinfo + ) + ); + // 请求成功 + echo($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} \ No newline at end of file diff --git a/sample/getObjectSensitiveContentRecognition.php b/sample/getObjectSensitiveContentRecognition.php index 8948e70f..1c0e7a06 100644 --- a/sample/getObjectSensitiveContentRecognition.php +++ b/sample/getObjectSensitiveContentRecognition.php @@ -17,7 +17,8 @@ $result = $cosClient->getObjectSensitiveContentRecognition(array( 'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID 'Key' => 'exampleobject', - 'DetectType' => 'porn,politics' //可选四种参数:porn,politics,terrorist,ads,可使用多种规则,注意规则间不要加空格 + 'DetectType' => 'porn,politics', //可选四种参数:porn,politics,terrorist,ads,可使用多种规则,注意规则间不要加空格 + 'ci-process' => 'sensitive-content-recognition', // 'Interval' => 5, // 审核gif时使用 截帧的间隔 // 'MaxFrames' => 5, // 针对 GIF 动图审核的最大截帧数量,需大于0。 // 'BizType' => '', // 审核策略 @@ -33,6 +34,7 @@ 'Key' => '/', // 链接图片资源路径写 / 即可 'DetectType' => 'porn,ads',//可选四种参数:porn,politics,terrorist,ads,可使用多种规则,注意规则间不要加空格 'DetectUrl' => $imgUrl, + 'ci-process' => 'sensitive-content-recognition', // 'Interval' => 5, // 审核gif时使用 截帧的间隔 // 'MaxFrames' => 5, // 针对 GIF 动图审核的最大截帧数量,需大于0。 // 'BizType' => '', // 审核策略 diff --git a/sample/getSnapshot.php b/sample/getSnapshot.php new file mode 100644 index 00000000..67634518 --- /dev/null +++ b/sample/getSnapshot.php @@ -0,0 +1,41 @@ + $region, + 'schema' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId , + 'secretKey' => $secretKey))); +$time = 3.14; +$local_path = "/data/exampleobject/test.jpg"; +try { + /* + * 如果访问400,media bucket unbinded, bucket's host is unavailable + * 请先在控制台开启媒体处理开关 + */ + $result = $cosClient->getSnapshot( + array( + 'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID + 'Key' =>'exampleobject', //桶中的媒体文件,如test.mp4 + 'ci-process' => 'snapshot', //操作类型,固定使用 snapshot + 'Time' => $time, //截图的时间点,单位为秒 + 'SaveAs' => $local_path, //本地保存路径 +// 'Width' => 0, +// 'Height' => 0, +// 'Format' => 'jpg', +// 'Rotate' => 'auto', +// 'Mode' => 'exactframe', + ) + ); + // 请求成功 + echo($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} \ No newline at end of file diff --git a/sample/putBucketReferer.php b/sample/putBucketReferer.php new file mode 100644 index 00000000..b118daf5 --- /dev/null +++ b/sample/putBucketReferer.php @@ -0,0 +1,35 @@ + $region, + 'schema' => 'https', //协议头部,默认为http + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + $result = $cosClient->putBucketReferer( + array( + 'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID + 'Status' => 'Enabled', //是否开启防盗链,枚举值:Enabled、Disabled + 'RefererType' => 'White-List', //防盗链类型,枚举值:Black-List、White-List + 'DomainList' => array( + 'Domains' => array( + '*.qq.com', + '*.qcloud.com', + ) + ), //生效域名列表 +// 'EmptyReferConfiguration' => 'Allow',//是否允许空 Referer 访问,枚举值:Allow、Deny,默认值为 Deny + ) + ); + // 请求成功 + echo($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} \ No newline at end of file diff --git a/sample/trafficLimit.php b/sample/trafficLimit.php index 65891dbe..1da6dc25 100644 --- a/sample/trafficLimit.php +++ b/sample/trafficLimit.php @@ -2,6 +2,7 @@ require dirname(__FILE__) . '/../vendor/autoload.php'; + $secretId = "SECRETID"; //"云 API 密钥 SecretId"; $secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey"; $region = "ap-beijing"; //设置一个默认的存储桶地域 @@ -12,8 +13,8 @@ 'credentials'=> array( 'secretId' => $secretId , 'secretKey' => $secretKey))); -$local_path = '/data/exampleobject'; +$local_path = '/data/exampleobject'; try { //上传对象,单链接限速 $result = $cosClient->putObject(array( diff --git a/src/Qcloud/Cos/Client.php b/src/Qcloud/Cos/Client.php index cd625588..bf5ad2a3 100644 --- a/src/Qcloud/Cos/Client.php +++ b/src/Qcloud/Cos/Client.php @@ -50,6 +50,7 @@ * @method object GetBucketTagging (array $arg) * @method object UploadPart (array $arg) * @method object PutObject (array $arg) + * @method object AppendObject (array $arg) * @method object PutObjectAcl (array $arg) * @method object PutBucketAcl (array $arg) * @method object PutBucketCors (array $arg) @@ -87,24 +88,27 @@ * @method object GetBucketImageStyle (array $arg) * @method object DeleteBucketImageStyle (array $arg) * @method object PutBucketGuetzli (array $arg) - * @method object AppendObject (array $arg) * @method object GetBucketGuetzli (array $arg) * @method object DeleteBucketGuetzli (array $arg) * @method object GetObjectSensitiveContentRecognition (array $arg) * @method object DetectText (array $arg) - * @method object GetDetectTextResult (array $arg) + * @method object GetSnapshot (array $arg) + * @method object PutBucketReferer (array $arg) + * @method object GetBucketReferer (array $arg) + * @method object GetMediaInfo (array $arg) * @method object CreateMediaTranscodeJobs (array $arg) * @method object CreateMediaSnapshotJobs (array $arg) * @method object CreateMediaConcatJobs (array $arg) * @method object DetectAudio (array $arg) * @method object GetDetectAudioResult (array $arg) + * @method object GetDetectTextResult (array $arg) * @method object DetectVideo (array $arg) * @method object GetDetectVideoResult (array $arg) * @method object DetectDocument (array $arg) * @method object GetDetectDocumentResult (array $arg) */ class Client extends GuzzleClient { - const VERSION = '2.3.1'; + const VERSION = '2.3.2'; public $httpClient; diff --git a/src/Qcloud/Cos/MultipartUpload.php b/src/Qcloud/Cos/MultipartUpload.php index 3a81c809..5c342e45 100644 --- a/src/Qcloud/Cos/MultipartUpload.php +++ b/src/Qcloud/Cos/MultipartUpload.php @@ -7,7 +7,7 @@ class MultipartUpload { const MIN_PART_SIZE = 1048576; const MAX_PART_SIZE = 5368709120; - const DEFAULT_PART_SIZE = 52428800; + const DEFAULT_PART_SIZE = 5242880; const MAX_PARTS = 10000; private $client; diff --git a/src/Qcloud/Cos/ResultTransformer.php b/src/Qcloud/Cos/ResultTransformer.php index c4cbaa88..27cf68e6 100644 --- a/src/Qcloud/Cos/ResultTransformer.php +++ b/src/Qcloud/Cos/ResultTransformer.php @@ -18,7 +18,7 @@ public function __construct($config, $operation) { public function writeDataToLocal(CommandInterface $command, RequestInterface $request, ResponseInterface $response) { $action = $command->getName(); - if ($action == "GetObject") { + if ($action == "GetObject" || $action == "GetSnapshot") { if (isset($command['SaveAs'])) { $fp = fopen($command['SaveAs'], "wb"); $stream = $response->getBody(); diff --git a/src/Qcloud/Cos/Service.php b/src/Qcloud/Cos/Service.php index a45f7a9c..3558c603 100644 --- a/src/Qcloud/Cos/Service.php +++ b/src/Qcloud/Cos/Service.php @@ -1454,6 +1454,145 @@ public static function getService() { ) ) ), + // 追加对象 + 'AppendObject' => array( + 'httpMethod' => 'POST', + 'uri' => '/{Bucket}{/Key*}?append', + 'class' => 'Qcloud\\Cos\\Command', + 'responseClass' => 'AppendObjectOutput', + 'responseType' => 'model', + 'data' => array( + 'xmlRoot' => array( + 'name' => 'AppendObjectRequest' + ) + ), + 'parameters' => array( + 'Position' => array( + 'type' => 'integer', + 'required' => true, + 'location' => 'query', + 'sentAs' => 'position' + ), + 'ACL' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-acl' + ), + 'Body' => array( + 'required' => true, + 'type' => array( + 'any' + ), + 'location' => 'body' + ), + 'Bucket' => array( + 'required' => true, + 'type' => 'string', + 'location' => 'uri' + ), + 'CacheControl' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Cache-Control' + ), + 'ContentDisposition' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Disposition' + ), + 'ContentEncoding' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Encoding' + ), + 'ContentLanguage' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Language' + ), + 'ContentLength' => array( + 'type' => 'numeric', + 'minimum'=> 0, + 'location' => 'header', + 'sentAs' => 'Content-Length' + ), + 'ContentMD5' => array( + 'type' => array( + 'boolean' + ), + 'location' => 'header', + 'sentAs' => 'Content-MD5' + ), + 'ContentType' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Type' + ), + 'Key' => array( + 'required' => true, + 'type' => 'string', + 'location' => 'uri', + 'minLength' => 1, + 'filters' => array( + 'Qcloud\\Cos\\Client::explodeKey' + ) + ), + 'ServerSideEncryption' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption', + ), + 'StorageClass' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-storage-class', + ), + 'WebsiteRedirectLocation' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-website-redirect-location', + ), + 'SSECustomerAlgorithm' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption-customer-algorithm', + ), + 'SSECustomerKey' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption-customer-key', + ), + 'SSECustomerKeyMD5' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption-customer-key-MD5', + ), + 'SSEKMSKeyId' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption-cos-kms-key-id', + ), + 'RequestPayer' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-request-payer', + ), + 'ACP' => array( + 'type' => 'object', + 'additionalProperties' => true, + ), + 'PicOperations' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Pic-Operations', + ), + 'TrafficLimit' => array( + 'type' => 'integer', + 'location' => 'header', + 'sentAs' => 'x-cos-traffic-limit', + ) + ) + ), // 设置 COS 对象的访问权限信息(Access Control List, ACL)的方法. 'PutObjectAcl' => array( 'httpMethod' => 'PUT', @@ -3399,7 +3538,7 @@ public static function getService() { //图片审核 'GetObjectSensitiveContentRecognition' => array( 'httpMethod' => 'GET', - 'uri' => '/{Bucket}{/Key*}?ci-process=sensitive-content-recognition', + 'uri' => '/{Bucket}{/Key*}', 'class' => 'Qcloud\\Cos\\Command', 'responseClass' => 'GetObjectSensitiveContentRecognitionOutput', 'responseType' => 'model', @@ -3409,6 +3548,11 @@ public static function getService() { 'type' => 'string', 'location' => 'uri', ), + 'ci-process' => array( + 'required' => true, + 'type' => 'string', + 'location' => 'query' + ), 'Key' => array( 'required' => true, 'type' => 'string', @@ -3498,91 +3642,259 @@ public static function getService() { ), ), ), - 'CreateMediaTranscodeJobs' => Descriptions::CreateMediaTranscodeJobs(), // 媒体转码 - 'CreateMediaSnapshotJobs' => Descriptions::CreateMediaSnapshotJobs(), // 媒体截图 - 'CreateMediaConcatJobs' => Descriptions::CreateMediaConcatJobs(), // 媒体拼接 - 'DetectAudio' => Descriptions::DetectAudio(), // 音频审核 - 'GetDetectAudioResult' => Descriptions::GetDetectAudioResult(), // 主动获取音频审核结果 - 'GetDetectTextResult' => Descriptions::GetDetectTextResult(), // 主动获取文本文件审核结果 - 'DetectVideo' => Descriptions::DetectVideo(), // 视频审核 - 'GetDetectVideoResult' => Descriptions::GetDetectVideoResult(), // 主动获取视频审核结果 - 'DetectDocument' => Descriptions::DetectDocument(), // 文档审核 - 'GetDetectDocumentResult' => Descriptions::GetDetectDocumentResult(), // 主动获取文档审核结果 - ), - 'models' => array( - 'AbortMultipartUploadOutput' => array( - 'type' => 'object', - 'additionalProperties' => true, - 'properties' => array( - 'RequestId' => array( - 'location' => 'header', - 'sentAs' => 'x-cos-request-id' - ) - ) - ), - 'CreateBucketOutput' => array( - 'type' => 'object', - 'additionalProperties' => true, - 'properties' => array( - 'Location' => array( + //媒体截图 + 'GetSnapshot' => array( + 'httpMethod' => 'GET', + 'uri' => '/{Bucket}{/Key*}', + 'class' => 'Qcloud\\Cos\\Command', + 'responseClass' => 'GetSnapshotOutput', + 'responseType' => 'model', + 'parameters' => array( + 'Bucket' => array( + 'required' => true, 'type' => 'string', - 'location' => 'header' + 'location' => 'uri', ), - 'RequestId' => array( - 'location' => 'header', - 'sentAs' => 'x-cos-request-id' - ) - ) - ), - 'CompleteMultipartUploadOutput' => array( - 'type' => 'object', - 'additionalProperties' => true, - 'properties' => array( - 'Location' => array( + 'Key' => array( + 'required' => true, 'type' => 'string', - 'location' => 'xml', + 'location' => 'uri', + 'minLength' => 1, + 'filters' => array( + 'Qcloud\\Cos\\Client::explodeKey' + ) ), - 'Bucket' => array( + 'Time' => array( + 'required' => true, + 'type' => 'numeric', + 'location' => 'query', + 'sentAs' => 'time' + ), + 'ci-process' => array( + 'required' => true, 'type' => 'string', - 'location' => 'xml', + 'location' => 'query' ), - 'Key' => array( + 'Width' => array( + 'type' => 'integer', + 'location' => 'query', + 'sentAs' => 'width' + ), + 'Height' => array( + 'type' => 'integer', + 'location' => 'query', + 'sentAs' => 'height' + ), + 'Format' => array( 'type' => 'string', - 'location' => 'xml' + 'location' => 'query', + 'sentAs' => 'format' ), - 'Expiration' => array( + 'Rotate' => array( 'type' => 'string', - 'location' => 'header', - 'sentAs' => 'x-cos-expiration', + 'location' => 'query', + 'sentAs' => 'rotate' ), - 'ETag' => array( + 'Mode' => array( 'type' => 'string', - 'location' => 'xml', + 'location' => 'query', + 'sentAs' => 'mode' + ) + ), + ), + //添加防盗链 + 'PutBucketReferer' => array( + 'httpMethod' => 'PUT', + 'uri' => '/{Bucket}?referer', + 'class' => 'Qcloud\\Cos\\Command', + 'responseClass' => 'PutBucketRefererOutput', + 'responseType' => 'model', + 'data' => array( + 'xmlRoot' => array( + 'name' => 'RefererConfiguration', ), - 'ServerSideEncryption' => array( + 'contentMd5' => true, + ), + 'parameters' => array( + 'Bucket' => array( + 'required' => true, 'type' => 'string', - 'location' => 'header', - 'sentAs' => 'x-cos-server-side-encryption', + 'location' => 'uri', ), - 'VersionId' => array( + 'Status' => array( + 'required' => true, 'type' => 'string', - 'location' => 'header', - 'sentAs' => 'x-cos-version-id', + 'location' => 'xml', ), - 'SSEKMSKeyId' => array( + 'RefererType' => array( + 'required' => true, 'type' => 'string', - 'location' => 'header', - 'sentAs' => 'x-cos-server-side-encryption-aws-kms-key-id', + 'location' => 'xml', ), - 'RequestCharged' => array( + 'EmptyReferConfiguration' => array( + 'required' => true, 'type' => 'string', - 'location' => 'header', - 'sentAs' => 'x-cos-request-charged', + 'location' => 'xml', + ), + + 'DomainList' => array( + 'location' => 'xml', + 'type' => 'object', + 'properties' => array( + 'Domains' => array( + 'type' => 'array', + 'data' => array( + 'xmlFlattened' => true, + ), + 'items' => array( + 'name' => 'Domain', + 'type' => 'string', + 'sentAs' => 'Domain', + ), + ) + ) + ), + ), + ), + //获取防盗链规则 + 'GetBucketReferer' => array( + 'httpMethod' => 'GET', + 'uri' => '/{Bucket}?referer', + 'class' => 'Qcloud\\Cos\\Command', + 'responseClass' => 'GetBucketRefererOutput', + 'responseType' => 'model', + 'data' => array( + 'xmlRoot' => array( + 'name' => 'RefererConfiguration', + ), + ), + 'parameters' => array( + 'Bucket' => array( + 'required' => true, + 'type' => 'string', + 'location' => 'uri' + ) + ) + ), + //获取媒体信息 + 'GetMediaInfo' => array( + 'httpMethod' => 'GET', + 'uri' => '/{Bucket}{/Key*}', + 'class' => 'Qcloud\\Cos\\Command', + 'responseClass' => 'GetMediaInfoOutput', + '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' + ) + ), + 'ci-process' => array( + 'required' => true, + 'type' => 'string', + 'location' => 'query' + ) + ), + ), + 'CreateMediaTranscodeJobs' => Descriptions::CreateMediaTranscodeJobs(), // 媒体转码 + 'CreateMediaSnapshotJobs' => Descriptions::CreateMediaSnapshotJobs(), // 媒体截图 + 'CreateMediaConcatJobs' => Descriptions::CreateMediaConcatJobs(), // 媒体拼接 + 'DetectAudio' => Descriptions::DetectAudio(), // 音频审核 + 'GetDetectAudioResult' => Descriptions::GetDetectAudioResult(), // 主动获取音频审核结果 + 'GetDetectTextResult' => Descriptions::GetDetectTextResult(), // 主动获取文本文件审核结果 + 'DetectVideo' => Descriptions::DetectVideo(), // 视频审核 + 'GetDetectVideoResult' => Descriptions::GetDetectVideoResult(), // 主动获取视频审核结果 + 'DetectDocument' => Descriptions::DetectDocument(), // 文档审核 + 'GetDetectDocumentResult' => Descriptions::GetDetectDocumentResult(), // 主动获取文档审核结果 + ), + 'models' => array( + 'AbortMultipartUploadOutput' => array( + 'type' => 'object', + 'additionalProperties' => true, + 'properties' => array( + 'RequestId' => array( + 'location' => 'header', + 'sentAs' => 'x-cos-request-id' + ) + ) + ), + 'CreateBucketOutput' => array( + 'type' => 'object', + 'additionalProperties' => true, + 'properties' => array( + 'Location' => array( + 'type' => 'string', + 'location' => 'header' + ), + 'RequestId' => array( + 'location' => 'header', + 'sentAs' => 'x-cos-request-id' + ) + ) + ), + 'CompleteMultipartUploadOutput' => array( + 'type' => 'object', + 'additionalProperties' => true, + 'properties' => array( + 'Location' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'Bucket' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'Key' => array( + 'type' => 'string', + 'location' => 'xml' + ), + 'Expiration' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-expiration', + ), + 'ETag' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'ServerSideEncryption' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption', + ), + 'VersionId' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-version-id', + ), + 'SSEKMSKeyId' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption-aws-kms-key-id', + ), + 'RequestCharged' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-request-charged', ), 'RequestId' => array( 'location' => 'header', 'sentAs' => 'x-cos-request-id', ), + 'CRC' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-hash-crc64ecma', + ), 'ImageInfo' => array( 'type' => 'object', 'location' => 'xml', @@ -3744,6 +4056,11 @@ public static function getService() { 'location' => 'header', 'sentAs' => 'x-cos-request-id', ), + 'CRC' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-hash-crc64ecma', + ) ), ), 'DeleteBucketOutput' => array( @@ -4087,6 +4404,11 @@ public static function getService() { 'location' => 'header', 'sentAs' => 'x-cos-request-id', ), + 'CRC' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-hash-crc64ecma', + ) ), ), 'GetObjectAclOutput' => array( @@ -4798,6 +5120,11 @@ public static function getService() { 'location' => 'header', 'sentAs' => 'x-cos-request-id', ), + 'CRC' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-hash-crc64ecma', + ) ), ), 'UploadPartCopyOutput' => array( @@ -4846,6 +5173,11 @@ public static function getService() { 'location' => 'header', 'sentAs' => 'x-cos-request-id', ), + 'CRC' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-hash-crc64ecma', + ) ), ), 'PutBucketAclOutput' => array( @@ -4916,6 +5248,11 @@ public static function getService() { 'instanceOf' => 'GuzzleHttp\\Psr7\\Stream', 'location' => 'body', ), + 'CRC' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-hash-crc64ecma', + ) ), ), 'AppendObjectOutput' => array( @@ -5768,6 +6105,11 @@ public static function getService() { 'RequestId' => array( 'location' => 'header', 'sentAs' => 'x-cos-request-id', + ), + 'CRC' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-hash-crc64ecma', ) ) ), @@ -6482,6 +6824,422 @@ public static function getService() { ), ), ), + 'GetSnapshotOutput' => array( + 'type' => 'object', + 'additionalProperties' => true, + 'properties' => array( + 'Body' => array( + 'type' => 'string', + 'instanceOf' => 'GuzzleHttp\\Psr7\\Stream', + 'location' => 'body', + ), + 'DeleteMarker' => array( + 'type' => 'boolean', + 'location' => 'header', + 'sentAs' => 'x-cos-delete-marker', + ), + 'AcceptRanges' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'accept-ranges', + ), + 'Expiration' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-expiration', + ), + 'Restore' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-restore', + ), + 'LastModified' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Last-Modified', + ), + 'ContentLength' => array( + 'type' => 'numeric', + 'minimum'=> 0, + 'location' => 'header', + 'sentAs' => 'Content-Length', + ), + 'ETag' => array( + 'type' => 'string', + 'location' => 'header', + ), + 'MissingMeta' => array( + 'type' => 'numeric', + 'location' => 'header', + 'sentAs' => 'x-cos-missing-meta', + ), + 'VersionId' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-version-id', + ), + 'CacheControl' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Cache-Control', + ), + 'ContentDisposition' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Disposition', + ), + 'ContentEncoding' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Encoding', + ), + 'ContentLanguage' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Language', + ), + 'ContentRange' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Range', + ), + 'ContentType' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Type', + ), + 'Expires' => array( + 'type' => 'string', + 'location' => 'header', + ), + 'WebsiteRedirectLocation' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-website-redirect-location', + ), + 'ServerSideEncryption' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption', + ), + 'SSECustomerAlgorithm' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption-customer-algorithm', + ), + 'SSECustomerKeyMD5' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption-customer-key-MD5', + ), + 'SSEKMSKeyId' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-server-side-encryption-aws-kms-key-id', + ), + 'StorageClass' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-storage-class', + ), + 'RequestCharged' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-request-charged', + ), + 'ReplicationStatus' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-replication-status', + ), + 'RequestId' => array( + 'location' => 'header', + 'sentAs' => 'x-cos-request-id', + ) + ) + ), + //设置防盗链 + 'PutBucketRefererOutput' => array( + 'type' => 'object', + 'additionalProperties' => true, + 'properties' => array( + 'ContentLength' => array( + 'type' => 'numeric', + 'minimum'=> 0, + 'location' => 'header', + 'sentAs' => 'Content-Length', + ), + 'ETag' => array( + 'type' => 'string', + 'location' => 'header', + ), + 'RequestId' => array( + 'location' => 'header', + 'sentAs' => 'x-cos-request-id', + ) + ) + ), + //获取防盗链规则 + 'GetBucketRefererOutput' => array( + 'type' => 'object', + 'additionalProperties' => true, + 'properties' => array( + 'RequestId' => array( + 'location' => 'header', + 'sentAs' => 'x-cos-request-id' + ), + 'ContentType' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Type', + ), + 'ContentLength' => array( + 'type' => 'numeric', + 'minimum'=> 0, + 'location' => 'header', + 'sentAs' => 'Content-Length', + ), + 'Status' => array( + 'type' => 'string', + 'location' => 'xml' + ), + 'RefererType' => array( + 'type' => 'string', + 'location' => 'xml' + ), + 'EmptyReferConfiguration' => array( + 'type' => 'string', + 'location' => 'xml' + ), + 'DomainList' => array( + 'location' => 'xml', + 'type' => 'object', + 'properties' => array( + 'Domains' => array( + 'type' => 'array', + 'data' => array( + 'xmlFlattened' => true, + ), + 'items' => array( + 'name' => 'Domain', + 'type' => 'string', + 'sentAs' => 'Domain', + ), + ) + ) + ) + ) + ), + 'GetMediaInfoOutput' => array( + 'type' => 'object', + 'additionalProperties' => true, + 'properties' => array( + 'RequestId' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'x-cos-request-id', + ), + 'ContentType' => array( + 'type' => 'string', + 'location' => 'header', + 'sentAs' => 'Content-Type', + ), + 'ContentLength' => array( + 'type' => 'numeric', + 'minimum'=> 0, + 'location' => 'header', + 'sentAs' => 'Content-Length', + ), + 'MediaInfo' => array( + 'type' => 'object', + 'location' => 'xml', + 'properties' => array( + 'Stream' => array( + 'type' => 'object', + 'location' => 'xml', + 'properties' => array( + 'JobId' => array( + 'type' => 'string', + ), + 'State' => array( + 'type' => 'string', + ), + 'Video' => array( + 'type' => 'object', + 'location' => 'xml', + 'properties' => array( + 'Index' => array( + 'type' => 'integer', + ), + 'CodecName' => array( + 'type' => 'string', + ), + 'CodecLongName' => array( + 'type' => 'string', + ), + 'CodecTimeBase' => array( + 'type' => 'string', + ), + 'CodecTag' => array( + 'type' => 'string', + ), + 'Profile' => array( + 'type' => 'string', + ), + 'Height' => array( + 'type' => 'integer', + ), + 'Width' => array( + 'type' => 'integer', + ), + 'HasBFrame' => array( + 'type' => 'integer', + ), + 'RefFrames' => array( + 'type' => 'integer', + ), + 'Sar' => array( + 'type' => 'string', + ), + 'Dar' => array( + 'type' => 'string', + ), + 'PixFormat' => array( + 'type' => 'string', + ), + 'FieldOrder' => array( + 'type' => 'string', + ), + 'Level' => array( + 'type' => 'integer', + ), + 'Fps' => array( + 'type' => 'integer', + ), + 'AvgFps' => array( + 'type' => 'string', + ), + 'Timebase' => array( + 'type' => 'string', + ), + 'StartTime' => array( + 'type' => 'numeric', + ), + 'Duration' => array( + 'type' => 'numeric', + ), + 'Bitrate' => array( + 'type' => 'numeric', + ), + 'NumFrames' => array( + 'type' => 'integer', + ), + 'Language' => array( + 'type' => 'string', + ) + ), + 'Audio' => array( + 'type' => 'object', + 'location' => 'xml', + 'properties' => array( + 'Index' => array( + 'type' => 'integer', + ), + 'CodecName' => array( + 'type' => 'string', + ), + 'CodecLongName' => array( + 'type' => 'string', + ), + 'CodecTimeBase' => array( + 'type' => 'string', + ), + 'CodecTagString' => array( + 'type' => 'string', + ), + 'CodecTag' => array( + 'type' => 'string', + ), + 'SampleFmt' => array( + 'type' => 'string', + ), + 'SampleRate' => array( + 'type' => 'integer', + ), + 'Channel' => array( + 'type' => 'integer', + ), + 'ChannelLayout' => array( + 'type' => 'string', + ), + 'Timebase' => array( + 'type' => 'string', + ), + 'StartTime' => array( + 'type' => 'numeric', + ), + 'Duration' => array( + 'type' => 'numeric', + ), + 'Bitrate' => array( + 'type' => 'numeric', + ), + 'Language' => array( + 'type' => 'string', + ) + ) + ), + 'Subtitle' => array( + 'type' => 'object', + 'location' => 'xml', + 'properties' => array( + 'Index' => array( + 'type' => 'integer', + ), + 'Language' => array( + 'type' => 'string', + ) + ) + ) + ), + ) + ), + 'Format' => array( + 'type' => 'object', + 'location' => 'xml', + 'properties' => array( + 'NumStream' => array( + 'type' => 'integer', + ), + 'NumProgram' => array( + 'type' => 'integer', + ), + 'FormatName' => array( + 'type' => 'string', + ), + 'FormatLongName' => array( + 'type' => 'string', + ), + 'StartTime' => array( + 'type' => 'numeric', + ), + 'Duration' => array( + 'type' => 'numeric', + ), + 'Bitrate' => array( + 'type' => 'integer', + ), + 'Size' => array( + 'type' => 'integer', + ) + ) + ) + ) + ) + + + ) + ), 'CreateMediaTranscodeJobsOutput' => Descriptions::CreateMediaTranscodeJobsOutput(), 'CreateMediaSnapshotJobsOutput' => Descriptions::CreateMediaSnapshotJobsOutput(), 'CreateMediaConcatJobsOutput' => Descriptions::CreateMediaConcatJobsOutput(), diff --git a/src/Qcloud/Cos/Tests/COSTest.php b/src/Qcloud/Cos/Tests/COSTest.php index 1165f60b..879ca336 100644 --- a/src/Qcloud/Cos/Tests/COSTest.php +++ b/src/Qcloud/Cos/Tests/COSTest.php @@ -2054,14 +2054,13 @@ public function testPutObjectTaggingObjectNonExisted() } } - /* * 文本检测 * * 200 */ public function testDetectText() { - $content = '约炮'; + $content = '敏感词'; try { $result = $this->cosClient->detectText(array( 'Bucket' => $this->bucket, //格式:BucketName-APPID @@ -2077,6 +2076,5 @@ public function testDetectText() { } catch (ServiceResponseException $e) { $this->assertFalse(true); } - } }