Skip to content

transform #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}