From 376f5e727a92210789f12b9541ec8d2d8227f633 Mon Sep 17 00:00:00 2001 From: lewzylu <327874225@qq.com> Date: Tue, 11 May 2021 17:59:16 +0800 Subject: [PATCH] updatet to 2.1.6 (#187) * update feature * update to 2.1.6 Co-authored-by: lewzylu --- CHANGELOG.md | 5 +++++ sample/cosClient.php | 1 + sample/selectObjectContent.php | 31 +++++++++++++++++++++++++++++++ src/Qcloud/Cos/Client.php | 4 +++- src/Qcloud/Cos/Service.php | 8 ++++---- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dba3fe0..7dc9a545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ cos-php-sdk-v5 Upgrade Guide ==================== +2.1.5 to 2.1.6 +---------- +- Add `allow_redirects` parameter +- Fix `selectObjectContent` interface + 2.1.3 to 2.1.5 ---------- - The `download` interface supports breakpoint diff --git a/sample/cosClient.php b/sample/cosClient.php index e5f7ba21..b1a965bf 100644 --- a/sample/cosClient.php +++ b/sample/cosClient.php @@ -19,6 +19,7 @@ 'proxy' => '', //代理服务器 'retry' => 10, //重试次数 'userAgent' => '', //UA + 'allow_redirects' => false, //是否follow302 'credentials'=> array( 'secretId' => $secretId , 'secretKey' => $secretKey, diff --git a/sample/selectObjectContent.php b/sample/selectObjectContent.php index 61fd4e94..e5e79946 100644 --- a/sample/selectObjectContent.php +++ b/sample/selectObjectContent.php @@ -52,3 +52,34 @@ // 请求失败 echo($e); } + +try { + $result = $cosClient->selectObjectContent(array( + 'Bucket' => $bucket, //格式:BucketName-APPID + 'Key' => $key, + 'Expression' => 'Select * from COSObject s', + 'ExpressionType' => 'SQL', + 'InputSerialization' => array( + 'CompressionType' => 'None', + 'JSON' => array( + 'Type' => 'DOCUMENT' + ) + ), + 'OutputSerialization' => array( + 'JSON' => array( + 'RecordDelimiter' => '\n', + ) + ), + 'RequestProgress' => array( + 'Enabled' => 'FALSE' + ) + )); + // 请求成功 + foreach ($result['Data'] as $data) { + // 迭代遍历select结果 + print_r($data); + } +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/src/Qcloud/Cos/Client.php b/src/Qcloud/Cos/Client.php index 74c7f389..f5b4990d 100644 --- a/src/Qcloud/Cos/Client.php +++ b/src/Qcloud/Cos/Client.php @@ -77,7 +77,7 @@ * @method object GetBucketIntelligentTiering (array $arg) */ class Client extends GuzzleClient { - const VERSION = '2.1.5'; + const VERSION = '2.1.6'; public $httpClient; @@ -108,6 +108,7 @@ public function __construct($cosConfig) { $this->cosConfig['retry'] = isset($cosConfig['retry']) ? $cosConfig['retry'] : 1; $this->cosConfig['userAgent'] = isset($cosConfig['userAgent']) ? $cosConfig['userAgent'] : 'cos-php-sdk-v5.'. Client::VERSION; $this->cosConfig['pathStyle'] = isset($cosConfig['pathStyle']) ? $cosConfig['pathStyle'] : false; + $this->cosConfig['allow_redirects'] = isset($cosConfig['allow_redirects']) ? $cosConfig['allow_redirects'] : false; $service = Service::getService(); $handler = HandlerStack::create(); @@ -130,6 +131,7 @@ public function __construct($cosConfig) { 'timeout' => $this->cosConfig['timeout'], 'handler' => $handler, 'proxy' => $this->cosConfig['proxy'], + 'allow_redirects' => $this->cosConfig['allow_redirects'] ]); $this->desc = new Description($service); $this->api = (array)($this->desc->getOperations()); diff --git a/src/Qcloud/Cos/Service.php b/src/Qcloud/Cos/Service.php index afb1a400..7da4ad12 100644 --- a/src/Qcloud/Cos/Service.php +++ b/src/Qcloud/Cos/Service.php @@ -2718,8 +2718,8 @@ public static function getService() { ) ), 'JSON' => array( - 'type' => 'string', - 'location' => 'object', + 'type' => 'object', + 'location' => 'xml', 'properties' => array( 'Type' => array( 'type' => 'string', @@ -2764,8 +2764,8 @@ public static function getService() { ) ), 'JSON' => array( - 'type' => 'string', - 'location' => 'object', + 'type' => 'object', + 'location' => 'xml', 'properties' => array( 'RecordDelimiter' => array( 'type' => 'string',