From 6bee36a00023a0ed898b78c0972b17df29166194 Mon Sep 17 00:00:00 2001 From: lewzylu <327874225@qq.com> Date: Tue, 15 Aug 2017 19:28:21 +0800 Subject: [PATCH 1/7] Update test file --- src/Qcloud/Cos/Tests/ObjectTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Qcloud/Cos/Tests/ObjectTest.php b/src/Qcloud/Cos/Tests/ObjectTest.php index 2db45c0b..324829d3 100644 --- a/src/Qcloud/Cos/Tests/ObjectTest.php +++ b/src/Qcloud/Cos/Tests/ObjectTest.php @@ -71,4 +71,13 @@ public function testGetObjectUrl() { $this->assertFalse(true, $e); } } + + public function testGetObjectUrl() { + try{ + $this->cosClient->createBucket(array('Bucket' => 'testbucket')); + $this->getObjectUrl('testbucket', 'hello.txt', '+10 minutes'); + } catch (\Exception $e) { + $this->assertFalse(true, $e); + } + } } \ No newline at end of file From 64ce5cd1a4fa692ef6ea119f5c5c899015a0c3b8 Mon Sep 17 00:00:00 2001 From: lewzylu <327874225@qq.com> Date: Tue, 15 Aug 2017 19:55:12 +0800 Subject: [PATCH 2/7] Update test file --- src/Qcloud/Cos/Tests/ObjectTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Qcloud/Cos/Tests/ObjectTest.php b/src/Qcloud/Cos/Tests/ObjectTest.php index 324829d3..f251b179 100644 --- a/src/Qcloud/Cos/Tests/ObjectTest.php +++ b/src/Qcloud/Cos/Tests/ObjectTest.php @@ -75,7 +75,7 @@ public function testGetObjectUrl() { public function testGetObjectUrl() { try{ $this->cosClient->createBucket(array('Bucket' => 'testbucket')); - $this->getObjectUrl('testbucket', 'hello.txt', '+10 minutes'); + $this->cosClient->getObjectUrl('testbucket', 'hello.txt', '+10 minutes'); } catch (\Exception $e) { $this->assertFalse(true, $e); } From 2844befa872ada16691f60f6bfd055665ee18556 Mon Sep 17 00:00:00 2001 From: lewzylu <327874225@qq.com> Date: Tue, 15 Aug 2017 19:28:21 +0800 Subject: [PATCH 3/7] Update test file --- src/Qcloud/Cos/Tests/ObjectTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Qcloud/Cos/Tests/ObjectTest.php b/src/Qcloud/Cos/Tests/ObjectTest.php index f251b179..e627c6d1 100644 --- a/src/Qcloud/Cos/Tests/ObjectTest.php +++ b/src/Qcloud/Cos/Tests/ObjectTest.php @@ -80,4 +80,13 @@ public function testGetObjectUrl() { $this->assertFalse(true, $e); } } + + public function testGetObjectUrl() { + try{ + $this->cosClient->createBucket(array('Bucket' => 'testbucket')); + $this->getObjectUrl('testbucket', 'hello.txt', '+10 minutes'); + } catch (\Exception $e) { + $this->assertFalse(true, $e); + } + } } \ No newline at end of file From af7ad7604672e6e8876d1650ef0eb3aa367c7aa3 Mon Sep 17 00:00:00 2001 From: lewzylu <327874225@qq.com> Date: Tue, 15 Aug 2017 19:55:12 +0800 Subject: [PATCH 4/7] Update test file --- src/Qcloud/Cos/Tests/ObjectTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Qcloud/Cos/Tests/ObjectTest.php b/src/Qcloud/Cos/Tests/ObjectTest.php index e627c6d1..e227045e 100644 --- a/src/Qcloud/Cos/Tests/ObjectTest.php +++ b/src/Qcloud/Cos/Tests/ObjectTest.php @@ -84,7 +84,7 @@ public function testGetObjectUrl() { public function testGetObjectUrl() { try{ $this->cosClient->createBucket(array('Bucket' => 'testbucket')); - $this->getObjectUrl('testbucket', 'hello.txt', '+10 minutes'); + $this->cosClient->getObjectUrl('testbucket', 'hello.txt', '+10 minutes'); } catch (\Exception $e) { $this->assertFalse(true, $e); } From 16596d7fdb0d4dc82ef73efd2a278f7fba2620be Mon Sep 17 00:00:00 2001 From: lewzylu <327874225@qq.com> Date: Tue, 22 Aug 2017 15:24:13 +0800 Subject: [PATCH 5/7] Update test file --- src/Qcloud/Cos/Tests/ObjectTest.php | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/Qcloud/Cos/Tests/ObjectTest.php b/src/Qcloud/Cos/Tests/ObjectTest.php index e227045e..2db45c0b 100644 --- a/src/Qcloud/Cos/Tests/ObjectTest.php +++ b/src/Qcloud/Cos/Tests/ObjectTest.php @@ -71,22 +71,4 @@ public function testGetObjectUrl() { $this->assertFalse(true, $e); } } - - public function testGetObjectUrl() { - try{ - $this->cosClient->createBucket(array('Bucket' => 'testbucket')); - $this->cosClient->getObjectUrl('testbucket', 'hello.txt', '+10 minutes'); - } catch (\Exception $e) { - $this->assertFalse(true, $e); - } - } - - public function testGetObjectUrl() { - try{ - $this->cosClient->createBucket(array('Bucket' => 'testbucket')); - $this->cosClient->getObjectUrl('testbucket', 'hello.txt', '+10 minutes'); - } catch (\Exception $e) { - $this->assertFalse(true, $e); - } - } } \ No newline at end of file From d00d0c5a790cd37e32bd047d66ebc819fa05f86a Mon Sep 17 00:00:00 2001 From: lewzylu <327874225@qq.com> Date: Thu, 7 Sep 2017 10:47:42 +0800 Subject: [PATCH 6/7] Fix test file --- src/Qcloud/Cos/Tests/ObjectTest.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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); } From 9cd47c5a5e972a27937504cf7e86ed696f9d8260 Mon Sep 17 00:00:00 2001 From: lewzylu <327874225@qq.com> Date: Thu, 7 Sep 2017 11:30:26 +0800 Subject: [PATCH 7/7] map region --- src/Qcloud/Cos/Client.php | 10 ++++++++++ 1 file changed, 10 insertions(+) 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'];