Skip to content

Commit 1f13fdb

Browse files
authored
Add Select/TrafficLimit (#139)
* Add traffic limit * Add TraffixLimit
1 parent a4a96b0 commit 1f13fdb

File tree

3 files changed

+180
-2
lines changed

3 files changed

+180
-2
lines changed

src/Qcloud/Cos/Client.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function __construct($cosConfig) {
4444
$this->cosConfig['ip'] = isset($cosConfig['ip']) ? $cosConfig['ip'] : null;
4545
$this->cosConfig['port'] = isset($cosConfig['port']) ? $cosConfig['port'] : null;
4646
$this->cosConfig['endpoint'] = isset($cosConfig['endpoint']) ? $cosConfig['endpoint'] : 'myqcloud.com';
47+
$this->cosConfig['domain'] = isset($cosConfig['domain']) ? $cosConfig['domain'] : null;
4748
$this->cosConfig['proxy'] = isset($cosConfig['proxy']) ? $cosConfig['proxy'] : null;
4849
$this->cosConfig['userAgent'] = isset($cosConfig['userAgent']) ? $cosConfig['userAgent'] : 'cos-php-sdk-v5.'. Client::VERSION;
4950
$this->cosConfig['pathStyle'] = isset($cosConfig['pathStyle']) ? $cosConfig['pathStyle'] : false;
@@ -161,7 +162,7 @@ public function getPresignetUrl($method, $args, $expires = null) {
161162
public function getObjectUrl($bucket, $key, $expires = null, array $args = array()) {
162163
$command = $this->getCommand('GetObject', $args + array('Bucket' => $bucket, 'Key' => $key));
163164
$request = $this->commandToRequestTransformer($command);
164-
return $this->createPresignedUrl($request, $expires);
165+
return $this->createPresignedUrl($request, $expires)->__toString();
165166
}
166167

167168
public function upload($bucket, $key, $body, $options = array()) {

src/Qcloud/Cos/CosTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public function bucketStyleTransformer(CommandInterface $command, RequestInterfa
5757
}
5858
}
5959
$origin_host = $bucketname. '.cos.' . $this->config['region'] . '.' . $this->config['endpoint'];
60+
// domain
61+
if ($this->config['domain'] != null) {
62+
origin_host = $this->config['domain']
63+
}
6064
$host = $origin_host;
6165
if ($this->config['ip'] != null) {
6266
$host = $this->config['ip'];

src/Qcloud/Cos/Service.php

Lines changed: 174 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,11 @@ public static function getService() {
747747
'location' => 'header',
748748
'sentAs' => 'x-cos-server-side-encryption-customer-key-MD5',
749749
),
750+
'TrafficLimit' => array(
751+
'type' => 'integer',
752+
'location' => 'header',
753+
'sentAs' => 'x-cos-traffic-limit',
754+
)
750755
)
751756
),
752757
// 获取 COS 对象的访问权限信息(Access Control List, ACL)的方法.
@@ -1063,6 +1068,11 @@ public static function getService() {
10631068
'type' => 'string',
10641069
'location' => 'header',
10651070
'sentAs' => 'x-cos-request-payer',
1071+
),
1072+
'TrafficLimit' => array(
1073+
'type' => 'integer',
1074+
'location' => 'header',
1075+
'sentAs' => 'x-cos-traffic-limit',
10661076
)
10671077
)
10681078
),
@@ -1192,6 +1202,11 @@ public static function getService() {
11921202
'type' => 'string',
11931203
'location' => 'header',
11941204
'sentAs' => 'Pic-Operations',
1205+
),
1206+
'TrafficLimit' => array(
1207+
'type' => 'integer',
1208+
'location' => 'header',
1209+
'sentAs' => 'x-cos-traffic-limit',
11951210
)
11961211
)
11971212
),
@@ -2625,7 +2640,153 @@ public static function getService() {
26252640
'sentAs' => 'x-cos-request-payer',
26262641
)
26272642
),
2628-
)
2643+
),
2644+
'SelectObjectContent' => array(
2645+
'httpMethod' => 'Post',
2646+
'uri' => '/{/Key*}?select&select-type=2',
2647+
'class' => 'Qcloud\\Cos\\Command',
2648+
'responseClass' => 'SelectObjectContentOutput',
2649+
'responseType' => 'model',
2650+
'data' => array(
2651+
'xmlRoot' => array(
2652+
'name' => 'SelectRequest',
2653+
),
2654+
'contentMd5' => true,
2655+
),
2656+
'parameters' => array(
2657+
'Bucket' => array(
2658+
'required' => true,
2659+
'type' => 'string',
2660+
'location' => 'uri',
2661+
),
2662+
'Key' => array(
2663+
'required' => true,
2664+
'type' => 'string',
2665+
'location' => 'uri',
2666+
'minLength' => 1,
2667+
'filters' => array(
2668+
'Qcloud\\Cos\\Client::explodeKey')
2669+
),
2670+
'Expression' => array(
2671+
'type' => 'string',
2672+
'location' => 'xml'
2673+
),
2674+
'ExpressionType' => array(
2675+
'type' => 'string',
2676+
'location' => 'xml'
2677+
),
2678+
'InputSerialization' => array(
2679+
'location' => 'xml',
2680+
'type' => 'object',
2681+
'properties' => array(
2682+
'CompressionType' => array(
2683+
'type' => 'string',
2684+
'location' => 'xml',
2685+
),
2686+
'CSV' => array(
2687+
'type' => 'object',
2688+
'location' => 'xml',
2689+
'properties' => array(
2690+
'FileHeaderInfo' => array(
2691+
'type' => 'string',
2692+
'location' => 'xml',
2693+
),
2694+
'RecordDelimiter' => array(
2695+
'type' => 'string',
2696+
'location' => 'xml',
2697+
),
2698+
'FieldDelimiter' => array(
2699+
'type' => 'string',
2700+
'location' => 'xml',
2701+
),
2702+
'QuoteCharacter' => array(
2703+
'type' => 'string',
2704+
'location' => 'xml',
2705+
),
2706+
'QuoteEscapeCharacter' => array(
2707+
'type' => 'string',
2708+
'location' => 'xml',
2709+
),
2710+
'Comments' => array(
2711+
'type' => 'string',
2712+
'location' => 'xml',
2713+
),
2714+
'AllowQuotedRecordDelimiter' => array(
2715+
'type' => 'string',
2716+
'location' => 'xml',
2717+
),
2718+
)
2719+
),
2720+
'JSON' => array(
2721+
'type' => 'string',
2722+
'location' => 'object',
2723+
'properties' => array(
2724+
'Type' => array(
2725+
'type' => 'string',
2726+
'location' => 'xml',
2727+
)
2728+
)
2729+
),
2730+
)
2731+
),
2732+
'OutputSerialization' => array(
2733+
'location' => 'xml',
2734+
'type' => 'object',
2735+
'properties' => array(
2736+
'CompressionType' => array(
2737+
'type' => 'string',
2738+
'location' => 'xml',
2739+
),
2740+
'CSV' => array(
2741+
'type' => 'object',
2742+
'location' => 'xml',
2743+
'properties' => array(
2744+
'QuoteFields' => array(
2745+
'type' => 'string',
2746+
'location' => 'xml',
2747+
),
2748+
'RecordDelimiter' => array(
2749+
'type' => 'string',
2750+
'location' => 'xml',
2751+
),
2752+
'FieldDelimiter' => array(
2753+
'type' => 'string',
2754+
'location' => 'xml',
2755+
),
2756+
'QuoteCharacter' => array(
2757+
'type' => 'string',
2758+
'location' => 'xml',
2759+
),
2760+
'QuoteEscapeCharacter' => array(
2761+
'type' => 'string',
2762+
'location' => 'xml',
2763+
),
2764+
)
2765+
),
2766+
'JSON' => array(
2767+
'type' => 'string',
2768+
'location' => 'object',
2769+
'properties' => array(
2770+
'RecordDelimiter' => array(
2771+
'type' => 'string',
2772+
'location' => 'xml',
2773+
)
2774+
)
2775+
),
2776+
)
2777+
),
2778+
'RequestProgress' => array(
2779+
'location' => 'xml',
2780+
'type' => 'object',
2781+
'properties' => array(
2782+
'Enabled' => array(
2783+
'type' => 'string',
2784+
'location' => 'xml',
2785+
),
2786+
)
2787+
),
2788+
),
2789+
),
26292790
),
26302791
'models' => array(
26312792
'AbortMultipartUploadOutput' => array(
@@ -4661,6 +4822,18 @@ public static function getService() {
46614822
),
46624823
),
46634824
),
4825+
4826+
'SelectObjectContentOutput' => array(
4827+
'type' => 'object',
4828+
'additionalProperties' => true,
4829+
'properties' => array(
4830+
'Data' => array(
4831+
'type' => 'string',
4832+
'instanceOf' => 'GuzzleHttp\\Psr7\\Stream',
4833+
'location' => 'body',
4834+
),
4835+
),
4836+
),
46644837
)
46654838
);
46664839
}

0 commit comments

Comments
 (0)