From 1a974ae664dbf576fc20ae46bffe9b5afba90a57 Mon Sep 17 00:00:00 2001 From: dtynn Date: Mon, 28 Apr 2014 17:34:43 +0800 Subject: [PATCH 01/12] =?UTF-8?q?urlencode=E5=AF=B9/=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qiniu/rs.php | 2 +- tests/RsTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qiniu/rs.php b/qiniu/rs.php index 1166b5d8..d2a94125 100644 --- a/qiniu/rs.php +++ b/qiniu/rs.php @@ -32,7 +32,7 @@ public function MakeRequest($baseUrl, $mac) // => $privateUrl function Qiniu_RS_MakeBaseUrl($domain, $key) // => $baseUrl { - $keyEsc = rawurlencode($key); + $keyEsc = str_replace("%2F", "/", rawurlencode($key)); return "http://$domain/$keyEsc"; } diff --git a/tests/RsTest.php b/tests/RsTest.php index 2368198c..b02375a2 100644 --- a/tests/RsTest.php +++ b/tests/RsTest.php @@ -88,5 +88,11 @@ public function testBatchDeleteMoveCopy() Qiniu_RS_BatchDelete($this->client, array($e2, $e3, $e4)); } + + public function testUrlEncode() { + $url = Qiniu_RS_MakeBaseUrl("www.qiniu.com", "a/b/c d"); + var_dump($url); + $this->assertEquals($url, "http://www.qiniu.com/a/b/c%20d"); + } } From 49c496e42b19f715af3f4123cec6f0adec4cb374 Mon Sep 17 00:00:00 2001 From: callmez Date: Fri, 23 May 2014 05:10:59 -0500 Subject: [PATCH 02/12] =?UTF-8?q?=E9=A2=84=E5=8A=A0=E8=BD=BDrs.php?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3ee4d3fc..138f681c 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,6 @@ "php": ">=5.2.4" }, "autoload": { - "psr-0": { "qiniu\\": "qiniu" } - } + "files": ["qiniu/rs.php"] + } } From d3ee88f18d12027c10e038ddd2888968f57db381 Mon Sep 17 00:00:00 2001 From: callmez Date: Fri, 23 May 2014 05:17:15 -0500 Subject: [PATCH 03/12] =?UTF-8?q?rs=5Futils=E5=8A=9F=E8=83=BD=E6=9B=B4?= =?UTF-8?q?=E5=85=A8=E9=9D=A2[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 138f681c..8e8aa9f7 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,6 @@ "php": ">=5.2.4" }, "autoload": { - "files": ["qiniu/rs.php"] + "files": ["qiniu/rs_utils.php"] } } From 1928da223b0fe90721b9f004f3e20e028f31ac81 Mon Sep 17 00:00:00 2001 From: longbai Date: Fri, 23 May 2014 18:53:48 +0800 Subject: [PATCH 04/12] travis remove 5.2, add 5.5 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 399de88c..a297decf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: php php: - - 5.2 - 5.3 - 5.4 + - 5.5 before_script: - export QINIU_ACCESS_KEY="Vhiv6a22kVN_zhtetbPNeG9sY3JUL1HG597EmBwQ" - export QINIU_SECRET_KEY="b5b5vNg5nnkwkPfW5ayicPE_pj6hqgKMQEaWQ6JD" From 45df7a3fbc71a45ae8ae6cb0e98efb6e9bd20078 Mon Sep 17 00:00:00 2001 From: longbai Date: Fri, 23 May 2014 18:59:15 +0800 Subject: [PATCH 05/12] recover 5.2 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a297decf..415177f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: php php: + - 5.2 - 5.3 - 5.4 - 5.5 From c0552832e61e50b461aff7d36e684528ad7401ab Mon Sep 17 00:00:00 2001 From: longbai Date: Fri, 23 May 2014 19:15:34 +0800 Subject: [PATCH 06/12] remove transform --- docs/README.gist.md | 2 -- docs/README.md | 2 -- qiniu/rs.php | 4 ---- tests/IoTest.php | 23 +---------------------- 4 files changed, 1 insertion(+), 30 deletions(-) diff --git a/docs/README.gist.md b/docs/README.gist.md index 5a2b15c7..dc582fac 100644 --- a/docs/README.gist.md +++ b/docs/README.gist.md @@ -316,8 +316,6 @@ SDK源码地址: public $DetectMime; // 可选。如果设为非0值,则忽略上传端传递的文件MimeType信息,使用七牛服务器侦测内容后的判断结果。 public $FsizeLimit; // 可选。int类型,超过限制大小的上传内容会被判为上传失败,返回413状态码。 public $SaveKey; // 可选。自定义资源名格式。 - public $Transform; // 可选。指定资源经过怎样的处理后再保存。 - public $FopTimeout; // 可选。int类型,指定transform的超时时间,如果文件处理超过此值,则认为上传失败。 public $MimeLimit; // 可选。限定上传的文件类型。 } diff --git a/docs/README.md b/docs/README.md index e8292767..1a1c8217 100644 --- a/docs/README.md +++ b/docs/README.md @@ -409,8 +409,6 @@ if ($err !== null) { public $DetectMime; // 可选。如果设为非0值,则忽略上传端传递的文件MimeType信息,使用七牛服务器侦测内容后的判断结果。 public $FsizeLimit; // 可选。int类型,超过限制大小的上传内容会被判为上传失败,返回413状态码。 public $SaveKey; // 可选。自定义资源名格式。 - public $Transform; // 可选。指定资源经过怎样的处理后再保存。 - public $FopTimeout; // 可选。int类型,指定transform的超时时间,如果文件处理超过此值,则认为上传失败。 public $MimeLimit; // 可选。限定上传的文件类型。 } diff --git a/qiniu/rs.php b/qiniu/rs.php index d2a94125..425ba8f3 100644 --- a/qiniu/rs.php +++ b/qiniu/rs.php @@ -55,7 +55,6 @@ class Qiniu_RS_PutPolicy public $SaveKey; public $PersistentOps; public $PersistentNotifyUrl; - public $Transform; public $FopTimeout; public $MimeLimit; @@ -109,9 +108,6 @@ 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; } diff --git a/tests/IoTest.php b/tests/IoTest.php index 746f1aca..089b65de 100644 --- a/tests/IoTest.php +++ b/tests/IoTest.php @@ -132,8 +132,7 @@ public function testPut_mimetype() { $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); } - public function testPut_exclusive() - { + public function testPut_exclusive() { $key = 'testPut_exclusive' . getTid(); $scope = $this->bucket . ':' . $key; $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); @@ -157,27 +156,7 @@ 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); - } public function testPut_mimeLimit() { $key = 'testPut_mimeLimit' . getTid(); $scope = $this->bucket . ':' . $key; From 141eabbc23cd92467649d877a4ca86dfb47a79a3 Mon Sep 17 00:00:00 2001 From: longbai Date: Fri, 23 May 2014 19:52:08 +0800 Subject: [PATCH 07/12] remove 5.5 support --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 415177f6..399de88c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ php: - 5.2 - 5.3 - 5.4 - - 5.5 before_script: - export QINIU_ACCESS_KEY="Vhiv6a22kVN_zhtetbPNeG9sY3JUL1HG597EmBwQ" - export QINIU_SECRET_KEY="b5b5vNg5nnkwkPfW5ayicPE_pj6hqgKMQEaWQ6JD" From 335e7a8b059a2c70777b2bba2a37e1acfc275d64 Mon Sep 17 00:00:00 2001 From: longbai Date: Fri, 23 May 2014 20:33:18 +0800 Subject: [PATCH 08/12] add 5.5 curl file --- qiniu/io.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/qiniu/io.php b/qiniu/io.php index 8f003495..c992eb56 100644 --- a/qiniu/io.php +++ b/qiniu/io.php @@ -34,7 +34,7 @@ function Qiniu_Put($upToken, $key, $body, $putExtra) // => ($putRet, $err) } if ($putExtra->Params) { foreach ($putExtra->Params as $k=>$v) { - $fields[$k] = $v; + $fields[$k] = $v; } } @@ -44,6 +44,23 @@ function Qiniu_Put($upToken, $key, $body, $putExtra) // => ($putRet, $err) return Qiniu_Client_CallWithMultipartForm($client, $QINIU_UP_HOST, $fields, $files); } +function createFile($filename, $mime) +{ + // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax + // See: https://wiki.php.net/rfc/curl-file-upload + if (function_exists('curl_file_create')) { + return curl_file_create($filename, $mime); + } + + // Use the old style if using an older version of PHP + $value = "@{$filename}" + if (!empty($mime)) { + $value .= ';type=' . $mime; + } + + return $value; +} + function Qiniu_PutFile($upToken, $key, $localFile, $putExtra) // => ($putRet, $err) { global $QINIU_UP_HOST; @@ -52,11 +69,7 @@ function Qiniu_PutFile($upToken, $key, $localFile, $putExtra) // => ($putRet, $e $putExtra = new Qiniu_PutExtra; } - if (!empty($putExtra->MimeType)) { - $localFile .= ';type=' . $putExtra->MimeType; - } - - $fields = array('token' => $upToken, 'file' => '@' . $localFile); + $fields = array('token' => $upToken, 'file' => createFile($localFile, $putExtra->MimeType)); if ($key === null) { $fname = '?'; } else { @@ -73,7 +86,7 @@ function Qiniu_PutFile($upToken, $key, $localFile, $putExtra) // => ($putRet, $e } if ($putExtra->Params) { foreach ($putExtra->Params as $k=>$v) { - $fields[$k] = $v; + $fields[$k] = $v; } } From baf485376b5bc60bf4e20709918405d71149b1bf Mon Sep 17 00:00:00 2001 From: longbai Date: Fri, 23 May 2014 20:33:31 +0800 Subject: [PATCH 09/12] add travis 5.5 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 399de88c..415177f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ php: - 5.2 - 5.3 - 5.4 + - 5.5 before_script: - export QINIU_ACCESS_KEY="Vhiv6a22kVN_zhtetbPNeG9sY3JUL1HG597EmBwQ" - export QINIU_SECRET_KEY="b5b5vNg5nnkwkPfW5ayicPE_pj6hqgKMQEaWQ6JD" From bb6ab0dd62b6c035e89665f07de5218276dc9fc2 Mon Sep 17 00:00:00 2001 From: longbai Date: Fri, 23 May 2014 20:37:32 +0800 Subject: [PATCH 10/12] tab2space --- qiniu/io.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiniu/io.php b/qiniu/io.php index c992eb56..80365e18 100644 --- a/qiniu/io.php +++ b/qiniu/io.php @@ -46,7 +46,7 @@ function Qiniu_Put($upToken, $key, $body, $putExtra) // => ($putRet, $err) function createFile($filename, $mime) { - // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax + // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax // See: https://wiki.php.net/rfc/curl-file-upload if (function_exists('curl_file_create')) { return curl_file_create($filename, $mime); From a5072915287c0d4b740706d7099faa3d228f473d Mon Sep 17 00:00:00 2001 From: longbai Date: Fri, 23 May 2014 20:39:56 +0800 Subject: [PATCH 11/12] fixed char --- qiniu/io.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiniu/io.php b/qiniu/io.php index 80365e18..d953dc7c 100644 --- a/qiniu/io.php +++ b/qiniu/io.php @@ -44,7 +44,7 @@ function Qiniu_Put($upToken, $key, $body, $putExtra) // => ($putRet, $err) return Qiniu_Client_CallWithMultipartForm($client, $QINIU_UP_HOST, $fields, $files); } -function createFile($filename, $mime) +function createFile($filename, $mime) { // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax // See: https://wiki.php.net/rfc/curl-file-upload From 8b1ed1c50c461c766a3adea2f428d2ebe85f1a38 Mon Sep 17 00:00:00 2001 From: longbai Date: Fri, 23 May 2014 20:45:11 +0800 Subject: [PATCH 12/12] add comma --- qiniu/io.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiniu/io.php b/qiniu/io.php index d953dc7c..d77a03bf 100644 --- a/qiniu/io.php +++ b/qiniu/io.php @@ -53,7 +53,7 @@ function createFile($filename, $mime) } // Use the old style if using an older version of PHP - $value = "@{$filename}" + $value = "@{$filename}"; if (!empty($mime)) { $value .= ';type=' . $mime; }