Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 7 additions & 33 deletions src/Qcloud/Cos/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Qcloud\Cos\TokenListener;

class Client extends GSClient {
const VERSION = '1.3.0';
const VERSION = '1.3.1';

private $region; // string: region.
private $credentials;
Expand All @@ -22,6 +22,8 @@ class Client extends GSClient {
private $timeout; // int: timeout
private $connect_timeout; // int: connect_timeout
private $signature;
private $schema;


public function __construct($config) {
$this->region = $config['region'];
Expand All @@ -37,6 +39,7 @@ public function __construct($config) {
'gz'=>'ap-guangzhou',
'cd'=>'ap-chengdu',
'sgp'=>'ap-singapore',);
$this->schema = isset($config['schema']) ? $config['schema'] : 'http';
$this->region = isset($regionmap[$this->region]) ? $regionmap[$this->region] : $this->region;
$this->credentials = $config['credentials'];
$this->appId = isset($config['credentials']['appId']) ? $config['credentials']['appId'] : null;
Expand All @@ -47,57 +50,28 @@ public function __construct($config) {
$this->connect_timeout = isset($config['connect_timeout']) ? $config['connect_timeout'] : 3600;
$this->signature = new signature($this->secretId, $this->secretKey);
parent::__construct(
'http://cos.' . $this->region . '.myqcloud.com/', // base url
$this->schema.'://cos.' . $this->region . '.myqcloud.com/', // base url
array('request.options' => array('timeout' => $this->timeout, 'connect_timeout' => $this->connect_timeout),
)); // show curl verbose or not

$desc = ServiceDescription::factory(Service::getService());
$this->setDescription($desc);
$this->setUserAgent('cos-php-sdk-v5.' . Client::VERSION, true);

$this->addSubscriber(new ExceptionListener());
$this->addSubscriber(new Md5Listener($this->signature));
$this->addSubscriber(new TokenListener($this->token));
$this->addSubscriber(new SignatureListener($this->secretId, $this->secretKey));
$this->addSubscriber(new BucketStyleListener($this->appId));

// Allow for specifying bodies with file paths and file handles
$this->addSubscriber(new UploadBodyListener(array('PutObject', 'UploadPart')));
}
public function set_config($config) {
$this->region = $config['region'];
$regionmap = array('cn-east'=>'ap-shanghai',
'cn-south'=>'ap-guangzhou',
'cn-north'=>'ap-beijing-1',
'cn-south-2'=>'ap-guangzhou-2',
'cn-southwest'=>'ap-chengdu',
'sg'=>'ap-singapore',
'tj'=>'ap-beijing-1',
'bj'=>'ap-beijing',
'sh'=>'ap-shanghai',
'gz'=>'ap-guangzhou',
'cd'=>'ap-chengdu',
'sgp'=>'ap-singapore',);
$this->region = isset($regionmap[$this->region]) ? $regionmap[$this->region] : $this->region;
$this->credentials = $config['credentials'];
$this->appId = isset($config['credentials']['appId']) ? $config['credentials']['appId'] : null;
$this->secretId = $config['credentials']['secretId'];
$this->secretKey = $config['credentials']['secretKey'];
$this->token = isset($config['credentials']['token']) ? $config['credentials']['token'] : null;
$this->timeout = isset($config['timeout']) ? $config['timeout'] : 3600;
$this->connect_timeout = isset($config['connect_timeout']) ? $config['connect_timeout'] : 3600;
$this->signature = new signature($this->secretId, $this->secretKey);
parent::__construct(
'http://cos.' . $this->region . '.myqcloud.com/', // base url
array('request.options' => array('timeout' => $this->timeout, 'connect_timeout' => $this->connect_timeout),
)); // show curl verbose or not
}

public function __destruct() {
}

public function __call($method, $args) {
return parent::__call(ucfirst($method), $args);
}

public function createAuthorization(RequestInterface $request, $expires)
{
if ($request->getClient() !== $this) {
Expand Down
17 changes: 0 additions & 17 deletions src/Qcloud/Cos/Tests/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,23 +778,6 @@ public function testPutObjectEncryption()
}
}

/*
* Copy大文件
* 200
*/
public function testCopyBigFile()
{
try {
$this->cosClient->createBucket(array('Bucket' => $this->bucket));
$this->cosClient->Copy($bucket = $this->bucket,
$key = 'test10G',
$copysource = 'lewzylu01-1251668577.cos.ap-guangzhou.myqcloud.com/test10G');
} catch (ServiceResponseException $e) {
$this->assertFalse(true, $e);
}
}


/*
* 上传文件Bucket不存在
* NoSuchBucket
Expand Down