Skip to content

Commit d67d04d

Browse files
committed
Merge pull request #62 from dtynn/wanglin/putPolicy_transform
transform
2 parents 4732c3b + 09b7048 commit d67d04d

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

docs/gist/logo.jpg

8.36 KB
Loading

qiniu/rs.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class Qiniu_RS_PutPolicy
5555
public $SaveKey;
5656
public $PersistentOps;
5757
public $PersistentNotifyUrl;
58+
public $Transform;
59+
public $FopTimeout;
5860

5961
public function __construct($scope)
6062
{
@@ -106,6 +108,12 @@ public function Token($mac) // => $token
106108
if (!empty($this->PersistentNotifyUrl)) {
107109
$policy['persistentNotifyUrl'] = $this->PersistentNotifyUrl;
108110
}
111+
if (!empty($this->Transform)) {
112+
$policy['transform'] = $this->Transform;
113+
}
114+
if (!empty($this->FopTimeout)) {
115+
$policy['fopTimeout'] = $this->FopTimeout;
116+
}
109117

110118
$b = json_encode($policy);
111119
return Qiniu_SignWithData($mac, $b);

tests/IoTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,26 @@ public function testPut_exclusive()
143143
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
144144
$this->assertNull($err);
145145
}
146+
public function testPut_transform() {
147+
$key = 'testPut_transform' . getTid();
148+
$scope = $this->bucket . ':' . $key;
149+
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
150+
151+
$putPolicy = new Qiniu_RS_PutPolicy($scope);
152+
$putPolicy->Transform = "imageMogr2/format/png";
153+
$putPolicy->ReturnBody = '{"key": $(key), "hash": $(etag), "mimeType":$(mimeType)}';
154+
$upToken = $putPolicy->Token(null);
155+
156+
list($ret, $err) = Qiniu_PutFile($upToken, $key, __file__, null);
157+
$this->assertNull($ret);
158+
$this->assertEquals($err->Err, "fop fail or timeout");
159+
var_dump($err);
160+
161+
$pic_path = "../docs/gist/logo.jpg";
162+
list($ret, $err) = Qiniu_PutFile($upToken, $key, $pic_path, null);
163+
$this->assertNull($err);
164+
$this->assertEquals($ret["mimeType"], "image/png");
165+
var_dump($ret);
166+
}
146167
}
147168

0 commit comments

Comments
 (0)