Skip to content

Commit fd9f03d

Browse files
committed
Merge pull request #63 from qiniu/develop
v6.1.6
2 parents 43c656c + 4acdcfc commit fd9f03d

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## CHANGE LOG
22

3+
### v6.1.6
4+
5+
2014-2-17 issues [#62](https://github.com/qiniu/php-sdk/pull/62)
6+
7+
- 上传策略[支持transform/fopTimeout字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-transform),用于支持对上传内容做一次同步的数据处理,并将结果作为最终资源保存
8+
9+
310
### v6.1.5
411

512
2014-2-13 issues [#59](https://github.com/qiniu/php-sdk/pull/59)

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)