Skip to content

Commit

Permalink
Merge pull request #63 from qiniu/develop
Browse files Browse the repository at this point in the history
v6.1.6
  • Loading branch information
xushiwei committed Feb 17, 2014
2 parents 43c656c + 4acdcfc commit fd9f03d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Binary file added docs/gist/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions qiniu/rs.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Qiniu_RS_PutPolicy
public $SaveKey;
public $PersistentOps;
public $PersistentNotifyUrl;
public $Transform;
public $FopTimeout;

public function __construct($scope)
{
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions tests/IoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit fd9f03d

Please sign in to comment.