From 09b7048ac341476edc2c03252f469b4bc11a8eae Mon Sep 17 00:00:00 2001 From: dtynn Date: Mon, 17 Feb 2014 11:40:25 +0800 Subject: [PATCH 1/3] transform --- docs/gist/logo.jpg | Bin 0 -> 8556 bytes qiniu/rs.php | 8 ++++++++ tests/IoTest.php | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 docs/gist/logo.jpg diff --git a/docs/gist/logo.jpg b/docs/gist/logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9c1a57e13d42e262f3c462e0429284478557d48b GIT binary patch literal 8556 zcmd6M2UJsA+vY)}E4lO{kgI@*AV}{-EzOj zK}P&H{OshPpPpi3WMpDzVP^TW$^TJBYX-Pjfl8o~k%0?1#l^tL#XxHZ zzyQF&^ylyxfPWQ+Q;esXm|5t<;Gj3C`h`AxMn?Lendl>?w+^Mh2TpS_ai3SX&dhVi zndO2nuVPq27OVJ;vKBt`LA-?0J-=`^c76dtAz{gjQkSGJE32rgscUHJ{ibhVc+=>X zg{76XjqP1Km-`P~-5$C>dh*miATTI6q7##n-=?I#d!P0xJ16&ZUVcGg zc|~PabxmzueQR5LM`zd9?w+CHk60j9jOg&MPo;U%$iR?8|dOF^rY>MnYCu3!Au- zIiByH-yl1`gfdQ&@Dtjf$o}_$h5uh6`!}$^a7_Vc7#Zk`$H)ah01Elzspss#CE)+t z8)G^VvjFA}GQ=51HCSOcnCeIOXPLJ*jH~@+%V!KZlpkJO=KvtW+dZq!1dX@CDzjPA z9Y%*HIrB5Y!E;i4;oW8GvC6@PH`15+=5Afd-E-@w0eCYM@sbF*iYb}ONKARW33G9; zx3s^%i^IIoaWOX)@?&tw)DR^c&Um-TM}967H12sZ?C1bRC9P5oSDJ)~sbcbZvKKW6 zI}9C_Es#&EM*X2m>zd?EO3?puCQqflZqUmPGSjOk$iMbyEs-t$=w9k|@v-c~Y>6bh zfh-#yJLLkI9@FmNclUgiui6INlt>Edt4^;b>>@YkX#f)wVSY>g1nNXq!<$8xu!N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8J4N6N(}+ zOl^~XtzOw33`$-!iiE;bE-xVDzMXV>PLo!pYf~w9;QsU#uuF zXlI!a8B3Km;^6QIRlK4o<=obg$Yu||{!9N!+ZaZa@Z=oRt2P|ZXm{_@TZ{!shAv>H zSf;26y;IrF&zHA8M$Pu33rOP72-I-P{~U+>Jj@VtK5>Bek)*ct@Q>(h8_T-f62gMY zaZ>#8wf1&E61963K^ol`Q9xPaHpc|>H$-#3z#`W1aUz z0>K+Q-VP1dy;_I2X-A%&aX(7g)@}(CSP})H!9K>!V>>4XB+@N4QC`9Q$99$cw!L|bE0Xx3&GbivFCr8 zz8D+~{`6b}EwBFFkDSCNYjD|JvV491etqT+2*2XlKKat;ov@clBlKqJ*8WXOG$j?| z*3Sw5hGBU+|EdX`;F<`yj_lmP&N`}}TO#=Y;MqISUYLHyg8B>POu5q3A(=|+-UGPX zkvuE@yTHp`&EQZ`yD_uloFl}i-JAQD@%^9w#%=w{J;qF8Bp!uBcVt{zMR9BMIgzq2*D6vH(1dCh|SDvy6HojG5ef!4g4Y)zhO2pPmQAVQ_nad|J~*V^;a5jimno9 z(YKIyi2uGL$ifAJ4VeP<0})@4IcUH&`gzl-`_)jq@y^89_cb|tTyfHA4FxmAc>_{d zbW~7ehk0CMRU@|?>ZJpl=_9B$CMl_Gvk4%&;E!-lNJ7TS@$9kgU6oc%RP>6sjnL|=|ML8e;qQ(6 SuaNt{IJf(M_#F#v^1lI>M|-FM literal 0 HcmV?d00001 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); + } } From 93d81de4b2c05c4c79e9f9001078d3e8dc118913 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 17 Feb 2014 12:00:30 +0800 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 628a55c8..d56deb6d 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) From 4acdcfc1729643d5c7a8d530d4d75fae78dfe9b3 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 17 Feb 2014 12:01:07 +0800 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d56deb6d..fb32f672 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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) +- 上传策略[支持transform/fopTimeout字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-transform),用于支持对上传内容做一次同步的数据处理,并将结果作为最终资源保存 ### v6.1.5