Skip to content

Commit bf63d14

Browse files
authored
Fix region and test (#8)
* Update test file * Update test file * Update test file * Update test file * Update test file * Fix test file * map region
1 parent 0590834 commit bf63d14

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Qcloud/Cos/Client.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class Client extends GSClient {
2424

2525
public function __construct($config) {
2626
$this->region = isset($config['region']) ? $config['region'] : '';
27+
$regionmap = array('cn-east'=>'ap-shanghai',
28+
'cn-sorth'=>'ap-guangzhou',
29+
'cn-north'=>'ap-beijing-1',
30+
'cn-south-2'=>'ap-guangzhou-2',
31+
'cn-southwest'=>'ap-chengdu',
32+
'sg'=>'ap-singapore');
33+
if (array_key_exists($this->region,$regionmap))
34+
{
35+
$this->region = $regionmap[$this->region];
36+
}
2737
$this->credentials = $config['credentials'];
2838
$this->appId = $config['credentials']['appId'];
2939
$this->secretId = $config['credentials']['secretId'];

src/Qcloud/Cos/Tests/ObjectTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@ public function testUploadSmallObject() {
4848
try {
4949
$result = $this->cosClient->createBucket(array('Bucket' => 'testbucket'));
5050
var_dump($result);
51-
$this->cosClient->upload('testbucket', 'hello.txt', 'Hello World');
51+
$this->cosClient->upload('testbucket', '你好.txt', 'Hello World');
52+
} catch (\Exception $e) {
53+
$this->assertFalse(true, $e);
54+
}
55+
}
56+
57+
public function testUploadComplexObject() {
58+
try {
59+
$result = $this->cosClient->createBucket(array('Bucket' => 'testbucket'));
60+
var_dump($result);
61+
$this->cosClient->upload('testbucket', '→↓←→↖↗↙↘! \"#$%&\'()*+,-./0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', 'Hello World');
5262
} catch (\Exception $e) {
5363
$this->assertFalse(true, $e);
5464
}

0 commit comments

Comments
 (0)