Skip to content

Commit 00a8520

Browse files
committed
putPolicy
1 parent c11dbc4 commit 00a8520

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/IoTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,56 @@ public function testPut_sizelimit()
6767
list($ret, $err) = Qiniu_Put($upToken, $key, "hello world!", null);
6868
$this->assertNull($ret);
6969
$this->assertEquals($err->Err, 'exceed FsizeLimit');
70+
var_dump($err);
71+
}
72+
73+
public function testPut_mime_save()
74+
{
75+
$key = 'testPut_mime_save' . getTid();
76+
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
77+
78+
$putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
79+
$putPolicy->DetectMime = 1;
80+
$putPolicy->SaveKey = $key;
81+
$upToken = $putPolicy->Token(null);
82+
$putExtra = new Qiniu_PutExtra();
83+
$putExtra->MimeType = 'image/jpg';
84+
list($ret, $err) = Qiniu_PutFile($upToken, null, __file__, $putExtra);
85+
$this->assertNull($err);
86+
87+
list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key);
88+
$this->assertNull($err);
89+
$this->assertEquals($ret['mimeType'], 'application/x-httpd-php');
90+
var_dump($ret);
91+
92+
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
93+
$this->assertNull($err);
94+
}
95+
96+
public function testPut_exclusive()
97+
{
98+
$key = 'testPut_exclusive' . getTid();
99+
$scope = $this->bucket . ':' . $key;
100+
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
101+
102+
$putPolicy = new Qiniu_RS_PutPolicy($scope);
103+
$putPolicy->InsertOnly = 1;
104+
$upToken = $putPolicy->Token(null);
105+
106+
list($ret, $err) = Qiniu_Put($upToken, $key, "hello world!", null);
107+
$this->assertNull($err);
108+
list($ret, $err) = Qiniu_PutFile($upToken, $key, __file__, null);
109+
$this->assertNull($ret);
110+
$this->assertEquals($err->Err, 'file exists');
111+
var_dump($err);
112+
113+
list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key);
114+
$this->assertNull($err);
115+
$this->assertEquals($ret['mimeType'], 'application/octet-stream');
70116
var_dump($ret);
117+
118+
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
119+
$this->assertNull($err);
71120
}
72121
}
73122

0 commit comments

Comments
 (0)