Skip to content

Commit 376f5e7

Browse files
lewzylulewzylu
andauthored
updatet to 2.1.6 (#187)
* update feature * update to 2.1.6 Co-authored-by: lewzylu <lewzylu@tencent.com>
1 parent ae23737 commit 376f5e7

File tree

5 files changed

+44
-5
lines changed

5 files changed

+44
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
cos-php-sdk-v5 Upgrade Guide
22
====================
3+
2.1.5 to 2.1.6
4+
----------
5+
- Add `allow_redirects` parameter
6+
- Fix `selectObjectContent` interface
7+
38
2.1.3 to 2.1.5
49
----------
510
- The `download` interface supports breakpoint

sample/cosClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'proxy' => '', //代理服务器
2020
'retry' => 10, //重试次数
2121
'userAgent' => '', //UA
22+
'allow_redirects' => false, //是否follow302
2223
'credentials'=> array(
2324
'secretId' => $secretId ,
2425
'secretKey' => $secretKey,

sample/selectObjectContent.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,34 @@
5252
// 请求失败
5353
echo($e);
5454
}
55+
56+
try {
57+
$result = $cosClient->selectObjectContent(array(
58+
'Bucket' => $bucket, //格式:BucketName-APPID
59+
'Key' => $key,
60+
'Expression' => 'Select * from COSObject s',
61+
'ExpressionType' => 'SQL',
62+
'InputSerialization' => array(
63+
'CompressionType' => 'None',
64+
'JSON' => array(
65+
'Type' => 'DOCUMENT'
66+
)
67+
),
68+
'OutputSerialization' => array(
69+
'JSON' => array(
70+
'RecordDelimiter' => '\n',
71+
)
72+
),
73+
'RequestProgress' => array(
74+
'Enabled' => 'FALSE'
75+
)
76+
));
77+
// 请求成功
78+
foreach ($result['Data'] as $data) {
79+
// 迭代遍历select结果
80+
print_r($data);
81+
}
82+
} catch (\Exception $e) {
83+
// 请求失败
84+
echo($e);
85+
}

src/Qcloud/Cos/Client.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
* @method object GetBucketIntelligentTiering (array $arg)
7878
*/
7979
class Client extends GuzzleClient {
80-
const VERSION = '2.1.5';
80+
const VERSION = '2.1.6';
8181

8282
public $httpClient;
8383

@@ -108,6 +108,7 @@ public function __construct($cosConfig) {
108108
$this->cosConfig['retry'] = isset($cosConfig['retry']) ? $cosConfig['retry'] : 1;
109109
$this->cosConfig['userAgent'] = isset($cosConfig['userAgent']) ? $cosConfig['userAgent'] : 'cos-php-sdk-v5.'. Client::VERSION;
110110
$this->cosConfig['pathStyle'] = isset($cosConfig['pathStyle']) ? $cosConfig['pathStyle'] : false;
111+
$this->cosConfig['allow_redirects'] = isset($cosConfig['allow_redirects']) ? $cosConfig['allow_redirects'] : false;
111112

112113
$service = Service::getService();
113114
$handler = HandlerStack::create();
@@ -130,6 +131,7 @@ public function __construct($cosConfig) {
130131
'timeout' => $this->cosConfig['timeout'],
131132
'handler' => $handler,
132133
'proxy' => $this->cosConfig['proxy'],
134+
'allow_redirects' => $this->cosConfig['allow_redirects']
133135
]);
134136
$this->desc = new Description($service);
135137
$this->api = (array)($this->desc->getOperations());

src/Qcloud/Cos/Service.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,8 +2718,8 @@ public static function getService() {
27182718
)
27192719
),
27202720
'JSON' => array(
2721-
'type' => 'string',
2722-
'location' => 'object',
2721+
'type' => 'object',
2722+
'location' => 'xml',
27232723
'properties' => array(
27242724
'Type' => array(
27252725
'type' => 'string',
@@ -2764,8 +2764,8 @@ public static function getService() {
27642764
)
27652765
),
27662766
'JSON' => array(
2767-
'type' => 'string',
2768-
'location' => 'object',
2767+
'type' => 'object',
2768+
'location' => 'xml',
27692769
'properties' => array(
27702770
'RecordDelimiter' => array(
27712771
'type' => 'string',

0 commit comments

Comments
 (0)