diff --git a/src/Qcloud/Cos/Client.php b/src/Qcloud/Cos/Client.php index 4bdc6459..70676ca9 100644 --- a/src/Qcloud/Cos/Client.php +++ b/src/Qcloud/Cos/Client.php @@ -44,6 +44,7 @@ public function __construct($cosConfig) { $this->cosConfig['ip'] = isset($cosConfig['ip']) ? $cosConfig['ip'] : null; $this->cosConfig['port'] = isset($cosConfig['port']) ? $cosConfig['port'] : null; $this->cosConfig['endpoint'] = isset($cosConfig['endpoint']) ? $cosConfig['endpoint'] : 'myqcloud.com'; + $this->cosConfig['domain'] = isset($cosConfig['domain']) ? $cosConfig['domain'] : null; $this->cosConfig['proxy'] = isset($cosConfig['proxy']) ? $cosConfig['proxy'] : null; $this->cosConfig['userAgent'] = isset($cosConfig['userAgent']) ? $cosConfig['userAgent'] : 'cos-php-sdk-v5.'. Client::VERSION; $this->cosConfig['pathStyle'] = isset($cosConfig['pathStyle']) ? $cosConfig['pathStyle'] : false; @@ -161,7 +162,7 @@ public function getPresignetUrl($method, $args, $expires = null) { public function getObjectUrl($bucket, $key, $expires = null, array $args = array()) { $command = $this->getCommand('GetObject', $args + array('Bucket' => $bucket, 'Key' => $key)); $request = $this->commandToRequestTransformer($command); - return $this->createPresignedUrl($request, $expires); + return $this->createPresignedUrl($request, $expires)->__toString(); } public function upload($bucket, $key, $body, $options = array()) { diff --git a/src/Qcloud/Cos/CosTransformer.php b/src/Qcloud/Cos/CosTransformer.php index ae0272d2..19b5d7d4 100644 --- a/src/Qcloud/Cos/CosTransformer.php +++ b/src/Qcloud/Cos/CosTransformer.php @@ -57,6 +57,10 @@ public function bucketStyleTransformer(CommandInterface $command, RequestInterfa } } $origin_host = $bucketname. '.cos.' . $this->config['region'] . '.' . $this->config['endpoint']; + // domain + if ($this->config['domain'] != null) { + origin_host = $this->config['domain'] + } $host = $origin_host; if ($this->config['ip'] != null) { $host = $this->config['ip']; diff --git a/src/Qcloud/Cos/Service.php b/src/Qcloud/Cos/Service.php index e1e7e17d..69adbf4e 100644 --- a/src/Qcloud/Cos/Service.php +++ b/src/Qcloud/Cos/Service.php @@ -747,6 +747,11 @@ public static function getService() { 'location' => 'header', 'sentAs' => 'x-cos-server-side-encryption-customer-key-MD5', ), + 'TrafficLimit' => array( + 'type' => 'integer', + 'location' => 'header', + 'sentAs' => 'x-cos-traffic-limit', + ) ) ), // 获取 COS 对象的访问权限信息(Access Control List, ACL)的方法. @@ -1063,6 +1068,11 @@ public static function getService() { 'type' => 'string', 'location' => 'header', 'sentAs' => 'x-cos-request-payer', + ), + 'TrafficLimit' => array( + 'type' => 'integer', + 'location' => 'header', + 'sentAs' => 'x-cos-traffic-limit', ) ) ), @@ -1192,6 +1202,11 @@ public static function getService() { 'type' => 'string', 'location' => 'header', 'sentAs' => 'Pic-Operations', + ), + 'TrafficLimit' => array( + 'type' => 'integer', + 'location' => 'header', + 'sentAs' => 'x-cos-traffic-limit', ) ) ), @@ -2625,7 +2640,153 @@ public static function getService() { 'sentAs' => 'x-cos-request-payer', ) ), - ) + ), + 'SelectObjectContent' => array( + 'httpMethod' => 'Post', + 'uri' => '/{/Key*}?select&select-type=2', + 'class' => 'Qcloud\\Cos\\Command', + 'responseClass' => 'SelectObjectContentOutput', + 'responseType' => 'model', + 'data' => array( + 'xmlRoot' => array( + 'name' => 'SelectRequest', + ), + 'contentMd5' => true, + ), + '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') + ), + 'Expression' => array( + 'type' => 'string', + 'location' => 'xml' + ), + 'ExpressionType' => array( + 'type' => 'string', + 'location' => 'xml' + ), + 'InputSerialization' => array( + 'location' => 'xml', + 'type' => 'object', + 'properties' => array( + 'CompressionType' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'CSV' => array( + 'type' => 'object', + 'location' => 'xml', + 'properties' => array( + 'FileHeaderInfo' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'RecordDelimiter' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'FieldDelimiter' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'QuoteCharacter' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'QuoteEscapeCharacter' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'Comments' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'AllowQuotedRecordDelimiter' => array( + 'type' => 'string', + 'location' => 'xml', + ), + ) + ), + 'JSON' => array( + 'type' => 'string', + 'location' => 'object', + 'properties' => array( + 'Type' => array( + 'type' => 'string', + 'location' => 'xml', + ) + ) + ), + ) + ), + 'OutputSerialization' => array( + 'location' => 'xml', + 'type' => 'object', + 'properties' => array( + 'CompressionType' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'CSV' => array( + 'type' => 'object', + 'location' => 'xml', + 'properties' => array( + 'QuoteFields' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'RecordDelimiter' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'FieldDelimiter' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'QuoteCharacter' => array( + 'type' => 'string', + 'location' => 'xml', + ), + 'QuoteEscapeCharacter' => array( + 'type' => 'string', + 'location' => 'xml', + ), + ) + ), + 'JSON' => array( + 'type' => 'string', + 'location' => 'object', + 'properties' => array( + 'RecordDelimiter' => array( + 'type' => 'string', + 'location' => 'xml', + ) + ) + ), + ) + ), + 'RequestProgress' => array( + 'location' => 'xml', + 'type' => 'object', + 'properties' => array( + 'Enabled' => array( + 'type' => 'string', + 'location' => 'xml', + ), + ) + ), + ), + ), ), 'models' => array( 'AbortMultipartUploadOutput' => array( @@ -4661,6 +4822,18 @@ public static function getService() { ), ), ), + + 'SelectObjectContentOutput' => array( + 'type' => 'object', + 'additionalProperties' => true, + 'properties' => array( + 'Data' => array( + 'type' => 'string', + 'instanceOf' => 'GuzzleHttp\\Psr7\\Stream', + 'location' => 'body', + ), + ), + ), ) ); }