From e1d1e35e32688cb85492d1b1cc4ce45a2b4ba240 Mon Sep 17 00:00:00 2001 From: rwifeng Date: Wed, 17 Jul 2013 10:19:41 +0800 Subject: [PATCH 01/14] callback verify --- qiniu/auth_digest.php | 19 +++++++++++++++++++ tests/AuthDigestTest.php | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/qiniu/auth_digest.php b/qiniu/auth_digest.php index ae78dc4a..7245e14b 100644 --- a/qiniu/auth_digest.php +++ b/qiniu/auth_digest.php @@ -46,6 +46,25 @@ public function SignRequest($req, $incbody) // => ($token, $error) } return $this->Sign($data); } + + public function VerifyCallback($auth, $url, $body) // ==> bool + { + + $url = parse_url($url); + + $data = ''; + if (isset($url['path'])) { + $data = $url['path']; + } + if (isset($url['query'])) { + $data .= '?' . $url['query']; + } + $data .= "\n"; + + $data .= $body; + $token = 'QBox ' . $this->Sign($data); + return $auth === $token; + } } function Qiniu_SetKeys($accessKey, $secretKey) diff --git a/tests/AuthDigestTest.php b/tests/AuthDigestTest.php index 07cc7a80..e8486f7b 100644 --- a/tests/AuthDigestTest.php +++ b/tests/AuthDigestTest.php @@ -4,6 +4,7 @@ class AuthDigestTest extends PHPUnit_Framework_TestCase { + public function testEncode() { $cases = array( @@ -16,6 +17,17 @@ public function testEncode() } } + public function testVerifyCallback() + { + initKeys(); + $mac1 = Qiniu_RequireMac(null); + $auth = 'QBox Vhiv6a22kVN_zhtetbPNeG9sY3JUL1HG597EmBwQ:JrRyg9So6DNrNDY5qj1sygt0SmQ='; + $url = 'http://rs.qbox.me/batch'; + $body = 'op=/delete/cGhwc2RrOnRlc3RPcDI=&op=/delete/cGhwc2RrOnRlc3RPcDM=&op=/delete/cGhwc2RrOnRlc3RPcDQ='; + $pass = $mac1->VerifyCallback($auth, $url, $body); + $this->assertTrue($pass); + } + /* public function testSetKeys() { $mac1 = Qiniu_RequireMac(null); From 422f8961cadcbb4b15cd7762dd42617915b54c58 Mon Sep 17 00:00:00 2001 From: rwifeng Date: Wed, 17 Jul 2013 10:23:48 +0800 Subject: [PATCH 02/14] fix --- qiniu/auth_digest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qiniu/auth_digest.php b/qiniu/auth_digest.php index 7245e14b..907acdbd 100644 --- a/qiniu/auth_digest.php +++ b/qiniu/auth_digest.php @@ -47,11 +47,9 @@ public function SignRequest($req, $incbody) // => ($token, $error) return $this->Sign($data); } - public function VerifyCallback($auth, $url, $body) // ==> bool + public function VerifyCallback($auth, $url, $body) // ==> bool { - $url = parse_url($url); - $data = ''; if (isset($url['path'])) { $data = $url['path']; From 25c74b9cb03894f1fe9e881686f96cec179c80fb Mon Sep 17 00:00:00 2001 From: dtynn Date: Mon, 31 Mar 2014 11:40:56 +0800 Subject: [PATCH 03/14] mimeLimit --- qiniu/rs.php | 5 +++++ tests/IoTest.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/qiniu/rs.php b/qiniu/rs.php index 9d3726ec..1166b5d8 100644 --- a/qiniu/rs.php +++ b/qiniu/rs.php @@ -57,6 +57,7 @@ class Qiniu_RS_PutPolicy public $PersistentNotifyUrl; public $Transform; public $FopTimeout; + public $MimeLimit; public function __construct($scope) { @@ -114,6 +115,10 @@ public function Token($mac) // => $token if (!empty($this->FopTimeout)) { $policy['fopTimeout'] = $this->FopTimeout; } + if (!empty($this->MimeLimit)) { + $policy['mimeLimit'] = $this->MimeLimit; + } + $b = json_encode($policy); return Qiniu_SignWithData($mac, $b); diff --git a/tests/IoTest.php b/tests/IoTest.php index f8510c60..305bbf2c 100644 --- a/tests/IoTest.php +++ b/tests/IoTest.php @@ -169,5 +169,19 @@ public function testPut_transform() { $this->assertEquals($ret["mimeType"], "image/png"); var_dump($ret); } + public function testPut_mimeLimit() { + $key = 'testPut_mimeLimit' . getTid(); + $scope = $this->bucket . ':' . $key; + $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); + + $putPolicy = new Qiniu_RS_PutPolicy($scope); + $putPolicy->MimeLimit = "image/*"; + $upToken = $putPolicy->Token(null); + + list($ret, $err) = Qiniu_PutFile($upToken, $key, __file__, null); + $this->assertNull($ret); + $this->assertEquals($err->Err, "limited mimeType: this file type is forbidden to upload"); + var_dump($err); + } } From e3404b6a56bfa8a86e463b9730e5688e950a4ef6 Mon Sep 17 00:00:00 2001 From: dtynn Date: Mon, 31 Mar 2014 11:54:04 +0800 Subject: [PATCH 04/14] docs add new put policy item --- docs/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/README.md b/docs/README.md index 2e1cf38a..ae560b9d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -253,6 +253,13 @@ SDK源码地址: public $Expires; // 可选。默认是 3600 秒 public $PersistentOps; // 可选。 public $PersistentNotifyUrl; // 如果设置了PersistentOps,必须同时设置此项。 + public $InsertOnly; // 可选。如果设置为非0值,则无论scope设置为何种形式,都只能以`新增`方式上传,不能覆盖。 + public $DetectMime; // 可选。如果设为非0值,则忽略上传端传递的文件MimeType信息,使用七牛服务器侦测内容后的判断结果。 + public $FsizeLimit; // 可选。int类型,超过限制大小的上传内容会被判为上传失败,返回413状态码。 + public $SaveKey; // 可选。自定义资源名格式。 + public $Transform; // 可选。指定资源经过怎样的处理后再保存。 + public $FopTimeout; // 可选。int类型,指定transform的超时时间,如果文件处理超过此值,则认为上传失败。 + public $MimeLimit; // 可选。限定上传的文件类型。 } * `scope` 限定客户端的权限。如果 `scope` 是 bucket,则客户端只能新增文件到指定的 bucket,不能修改文件。如果 `scope` 为 bucket:key,则客户端可以修改指定的文件。**注意: key必须采用utf8编码,如使用非utf8编码访问七牛云存储将反馈错误** From 25452c0b09325a0e659986b449a7410110613883 Mon Sep 17 00:00:00 2001 From: dtynn Date: Mon, 31 Mar 2014 12:00:35 +0800 Subject: [PATCH 05/14] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36ff898f..f1db2c17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## CHANGE LOG +### v6.1.8 + +2014-3-31 issues [#66](https://github.com/qiniu/php-sdk/pull/66) + +- 上传策略[支持mimeLimit字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-mime-limit),用于限定上传文件的mimeType。 + ### v6.1.7 2014-2-19 issues [#64](https://github.com/qiniu/php-sdk/pull/64) From 9e1c22ef5b6100a8db0bfb933f7b5fcd30b80512 Mon Sep 17 00:00:00 2001 From: dtynn Date: Thu, 3 Apr 2014 13:55:40 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E7=94=A8=E8=8C=83=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/gist/fetch.php | 32 ++++++++++++++++++++++++++++++++ docs/gist/pfop.php | 39 +++++++++++++++++++++++++++++++++++++++ docs/gist/prefetch.php | 29 +++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 docs/gist/fetch.php create mode 100644 docs/gist/pfop.php create mode 100644 docs/gist/prefetch.php diff --git a/docs/gist/fetch.php b/docs/gist/fetch.php new file mode 100644 index 00000000..7477a94d --- /dev/null +++ b/docs/gist/fetch.php @@ -0,0 +1,32 @@ + Date: Thu, 3 Apr 2014 14:01:18 +0800 Subject: [PATCH 07/14] new line at end --- docs/gist/fetch.php | 2 +- docs/gist/pfop.php | 2 +- docs/gist/prefetch.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/gist/fetch.php b/docs/gist/fetch.php index 7477a94d..3514eca3 100644 --- a/docs/gist/fetch.php +++ b/docs/gist/fetch.php @@ -29,4 +29,4 @@ var_dump($err); } else { echo "success\n"; -} \ No newline at end of file +} diff --git a/docs/gist/pfop.php b/docs/gist/pfop.php index dec552f5..f7c7c061 100644 --- a/docs/gist/pfop.php +++ b/docs/gist/pfop.php @@ -36,4 +36,4 @@ } else { echo "success\n"; var_dump($ret); -} \ No newline at end of file +} diff --git a/docs/gist/prefetch.php b/docs/gist/prefetch.php index 49373d50..8975880d 100644 --- a/docs/gist/prefetch.php +++ b/docs/gist/prefetch.php @@ -26,4 +26,4 @@ var_dump($err); } else { echo "success\n"; -} \ No newline at end of file +} From f6f5551a2423b4f13c673efd04528e451bda36b8 Mon Sep 17 00:00:00 2001 From: dtynn Date: Thu, 3 Apr 2014 14:06:52 +0800 Subject: [PATCH 08/14] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1db2c17..505ac769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## CHANGE LOG +### v6.1.9 + +2014-3-31 issues [#67](https://github.com/qiniu/php-sdk/pull/67) + +- 新增3个新接口:fetch、prefetch、pfop的调用范例代码,需要使用这三个接口的用户可以参考。 + ### v6.1.8 2014-3-31 issues [#66](https://github.com/qiniu/php-sdk/pull/66) From 52bbb343c66f9eb2be952fd6aaf7245acecde533 Mon Sep 17 00:00:00 2001 From: dtynn Date: Thu, 3 Apr 2014 14:07:42 +0800 Subject: [PATCH 09/14] changedate --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 505ac769..e91ed9ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### v6.1.9 -2014-3-31 issues [#67](https://github.com/qiniu/php-sdk/pull/67) +2014-04-03 issues [#67](https://github.com/qiniu/php-sdk/pull/67) - 新增3个新接口:fetch、prefetch、pfop的调用范例代码,需要使用这三个接口的用户可以参考。 From c3bc4267ddc01cf20c6b9a744296ee6c8ef74094 Mon Sep 17 00:00:00 2001 From: dtynn Date: Fri, 4 Apr 2014 16:21:33 +0800 Subject: [PATCH 10/14] api host fix --- docs/gist/pfop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gist/pfop.php b/docs/gist/pfop.php index f7c7c061..09043b60 100644 --- a/docs/gist/pfop.php +++ b/docs/gist/pfop.php @@ -19,7 +19,7 @@ $encodedFops = urlencode($fops); $encodedNotifyURL = urlencode($notifyURL); -$apiHost = "http://iovip.qbox.me"; +$apiHost = "http://api.qiniu.com"; $apiPath = "/pfop/"; $requestBody = "bucket=$encodedBucket&key=$encodedKey&fops=$encodedFops¬ifyURL=$encodedNotifyURL"; if ($force !== 0) { From 5d13c97d2b8bf7ceebb1273ac29a8a35434a77b9 Mon Sep 17 00:00:00 2001 From: longbai Date: Sat, 5 Apr 2014 23:06:03 +0800 Subject: [PATCH 11/14] update logo and copyright --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 53c7cd14..0c7ecb1c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://api.travis-ci.org/qiniu/php-sdk.png?branch=master)](https://travis-ci.org/qiniu/php-sdk) -[![Qiniu Logo](http://qiniutek.com/images/logo-2.png)](http://qiniu.com/) +[![Qiniu Logo](http://qiniu-brand.qiniudn.com/5/logo-white-195x105.png)](http://www.qiniu.com/) ## 下载 @@ -34,7 +34,7 @@ ## 许可证 -Copyright (c) 2012 qiniu.com +Copyright (c) 2012-2014 qiniu.com 基于 MIT 协议发布: From 9354bd601b3c0311a150be52b34ce8377f9a64f8 Mon Sep 17 00:00:00 2001 From: longbai Date: Sat, 5 Apr 2014 23:06:30 +0800 Subject: [PATCH 12/14] new release --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1db2c17..b4c7ff01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,10 @@ ### v6.1.8 -2014-3-31 issues [#66](https://github.com/qiniu/php-sdk/pull/66) +2014-4-6 issues [#68](https://github.com/qiniu/php-sdk/pull/68) -- 上传策略[支持mimeLimit字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-mime-limit),用于限定上传文件的mimeType。 +- [#66]上传策略[支持mimeLimit字段](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-mime-limit),用于限定上传文件的mimeType。 +- [#67] 新增接口的调用范例 ### v6.1.7 From 15795894078dcf0cf73b7d9c0fb90d245baf3d28 Mon Sep 17 00:00:00 2001 From: longbai Date: Sat, 5 Apr 2014 23:06:59 +0800 Subject: [PATCH 13/14] remove newline end --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c5845f1f..b32c5893 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,3 @@ before_script: - export QINIU_KEY_NAME="file_name" script: - cd tests; phpunit . - From fff5a5d37c75c139e30d0952bdc2188b9e2b88f0 Mon Sep 17 00:00:00 2001 From: longbai Date: Sat, 5 Apr 2014 23:11:34 +0800 Subject: [PATCH 14/14] update changelog --- CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38d886da..b4c7ff01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,5 @@ ## CHANGE LOG -### v6.1.9 - -2014-04-03 issues [#67](https://github.com/qiniu/php-sdk/pull/67) - -- 新增3个新接口:fetch、prefetch、pfop的调用范例代码,需要使用这三个接口的用户可以参考。 - ### v6.1.8 2014-4-6 issues [#68](https://github.com/qiniu/php-sdk/pull/68)