diff --git a/src/Qcloud/Cos/Client.php b/src/Qcloud/Cos/Client.php index 2c0b02fc..42ee1ed5 100644 --- a/src/Qcloud/Cos/Client.php +++ b/src/Qcloud/Cos/Client.php @@ -24,6 +24,16 @@ class Client extends GSClient { public function __construct($config) { $this->region = isset($config['region']) ? $config['region'] : ''; + $regionmap = array('cn-east'=>'ap-shanghai', + 'cn-sorth'=>'ap-guangzhou', + 'cn-north'=>'ap-beijing-1', + 'cn-south-2'=>'ap-guangzhou-2', + 'cn-southwest'=>'ap-chengdu', + 'sg'=>'ap-singapore'); + if (array_key_exists($this->region,$regionmap)) + { + $this->region = $regionmap[$this->region]; + } $this->credentials = $config['credentials']; $this->appId = $config['credentials']['appId']; $this->secretId = $config['credentials']['secretId']; diff --git a/src/Qcloud/Cos/Tests/ObjectTest.php b/src/Qcloud/Cos/Tests/ObjectTest.php index 2db45c0b..a055eae4 100644 --- a/src/Qcloud/Cos/Tests/ObjectTest.php +++ b/src/Qcloud/Cos/Tests/ObjectTest.php @@ -48,7 +48,17 @@ public function testUploadSmallObject() { try { $result = $this->cosClient->createBucket(array('Bucket' => 'testbucket')); var_dump($result); - $this->cosClient->upload('testbucket', 'hello.txt', 'Hello World'); + $this->cosClient->upload('testbucket', '你好.txt', 'Hello World'); + } catch (\Exception $e) { + $this->assertFalse(true, $e); + } + } + + public function testUploadComplexObject() { + try { + $result = $this->cosClient->createBucket(array('Bucket' => 'testbucket')); + var_dump($result); + $this->cosClient->upload('testbucket', '→↓←→↖↗↙↘! \"#$%&\'()*+,-./0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', 'Hello World'); } catch (\Exception $e) { $this->assertFalse(true, $e); }