diff --git a/CHANGELOG.md b/CHANGELOG.md index 628a55c8..fb32f672 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ## CHANGE LOG +### v6.1.6 + +2014-2-17 issues [#62](https://github.com/qiniu/php-sdk/pull/62) + +- 上传策略[支持transform/fopTimeout字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-transform),用于支持对上传内容做一次同步的数据处理,并将结果作为最终资源保存 + + ### v6.1.5 2014-2-13 issues [#59](https://github.com/qiniu/php-sdk/pull/59) diff --git a/docs/gist/logo.jpg b/docs/gist/logo.jpg new file mode 100644 index 00000000..9c1a57e1 Binary files /dev/null and b/docs/gist/logo.jpg differ diff --git a/qiniu/rs.php b/qiniu/rs.php index db79caa3..9d3726ec 100644 --- a/qiniu/rs.php +++ b/qiniu/rs.php @@ -55,6 +55,8 @@ class Qiniu_RS_PutPolicy public $SaveKey; public $PersistentOps; public $PersistentNotifyUrl; + public $Transform; + public $FopTimeout; public function __construct($scope) { @@ -106,6 +108,12 @@ public function Token($mac) // => $token if (!empty($this->PersistentNotifyUrl)) { $policy['persistentNotifyUrl'] = $this->PersistentNotifyUrl; } + if (!empty($this->Transform)) { + $policy['transform'] = $this->Transform; + } + if (!empty($this->FopTimeout)) { + $policy['fopTimeout'] = $this->FopTimeout; + } $b = json_encode($policy); return Qiniu_SignWithData($mac, $b); diff --git a/tests/IoTest.php b/tests/IoTest.php index 5ba0fd0f..488ca0e5 100644 --- a/tests/IoTest.php +++ b/tests/IoTest.php @@ -143,5 +143,26 @@ public function testPut_exclusive() $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); } + public function testPut_transform() { + $key = 'testPut_transform' . getTid(); + $scope = $this->bucket . ':' . $key; + $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); + + $putPolicy = new Qiniu_RS_PutPolicy($scope); + $putPolicy->Transform = "imageMogr2/format/png"; + $putPolicy->ReturnBody = '{"key": $(key), "hash": $(etag), "mimeType":$(mimeType)}'; + $upToken = $putPolicy->Token(null); + + list($ret, $err) = Qiniu_PutFile($upToken, $key, __file__, null); + $this->assertNull($ret); + $this->assertEquals($err->Err, "fop fail or timeout"); + var_dump($err); + + $pic_path = "../docs/gist/logo.jpg"; + list($ret, $err) = Qiniu_PutFile($upToken, $key, $pic_path, null); + $this->assertNull($err); + $this->assertEquals($ret["mimeType"], "image/png"); + var_dump($ret); + } }