From 3da9da32db2d46c10dc5876883866e1edfe3bcab Mon Sep 17 00:00:00 2001 From: anka <425732469@qq.com> Date: Fri, 8 Nov 2019 14:47:47 +0800 Subject: [PATCH 01/10] Update BucketManager.php Use the v3 version of the interface --- src/Qiniu/Storage/BucketManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Qiniu/Storage/BucketManager.php b/src/Qiniu/Storage/BucketManager.php index 0a2413dd..dacb5afe 100644 --- a/src/Qiniu/Storage/BucketManager.php +++ b/src/Qiniu/Storage/BucketManager.php @@ -74,7 +74,7 @@ public function listbuckets( */ public function createBucket($name, $region = 'z0') { - $path = '/mkbucketv2/'.$name.'/region/' . $region; + $path = '/mkbucketv3/'.$name.'/region/' . $region; return $this->rsPost($path, null); } From aba45bf113bd33ee2504e0899fbf0b17ce4df3a7 Mon Sep 17 00:00:00 2001 From: anka <425732469@qq.com> Date: Fri, 8 Nov 2019 14:50:01 +0800 Subject: [PATCH 02/10] Update BucketManager.php --- src/Qiniu/Storage/BucketManager.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Qiniu/Storage/BucketManager.php b/src/Qiniu/Storage/BucketManager.php index dacb5afe..40b7a9a7 100644 --- a/src/Qiniu/Storage/BucketManager.php +++ b/src/Qiniu/Storage/BucketManager.php @@ -68,8 +68,10 @@ public function listbuckets( * 创建空间 * * @param $name 创建的空间名 + * BucketName不满足以上要求返回400 (the specified bucket is not valid) + * 如果BucketName已经被使用,返回614(bucket exists) * @param $region 创建的区域,默认华东 - * + * * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error */ public function createBucket($name, $region = 'z0') From bd7c1c1897c3bc8ae3e65d0a79307efa77689124 Mon Sep 17 00:00:00 2001 From: anka <425732469@qq.com> Date: Fri, 22 Nov 2019 11:58:28 +0800 Subject: [PATCH 03/10] Update rs_batch_move.php --- examples/rs_batch_move.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rs_batch_move.php b/examples/rs_batch_move.php index 89225221..73bfc9e2 100644 --- a/examples/rs_batch_move.php +++ b/examples/rs_batch_move.php @@ -21,7 +21,7 @@ $keyPairs = array(); foreach ($keys as $key) { - $keyPairs[$key . "_copy"] = $key . "_move"; + $keyPairs[$key] = $key . "_move"; } $srcBucket = $bucket; From 2c33dcb112d9bc0b714f683dc23de7c6c1cb6caa Mon Sep 17 00:00:00 2001 From: anka <425732469@qq.com> Date: Thu, 19 Mar 2020 14:36:42 +0800 Subject: [PATCH 04/10] Update BucketManager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加归档存储接口 --- examples/rs_change_type.php | 2 +- examples/rs_restore_file.php | 20 ++++++++++++++++++++ src/Qiniu/Storage/BucketManager.php | 21 ++++++++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 examples/rs_restore_file.php diff --git a/examples/rs_change_type.php b/examples/rs_change_type.php index acb89635..ce34aa8a 100644 --- a/examples/rs_change_type.php +++ b/examples/rs_change_type.php @@ -12,7 +12,7 @@ $config = new \Qiniu\Config(); $bucketManager = new \Qiniu\Storage\BucketManager($auth, $config); -$fileType = 1;//0 表示普通存储,1表示低频存储 +$fileType = 1;//0 表示普通存储,1表示低频存储,2表示归档存储 $err = $bucketManager->changeType($bucket, $key, $fileType); if ($err) { diff --git a/examples/rs_restore_file.php b/examples/rs_restore_file.php new file mode 100644 index 00000000..580fd869 --- /dev/null +++ b/examples/rs_restore_file.php @@ -0,0 +1,20 @@ +restoreFile($bucket, $key, $day); +if ($err) { + print_r($err); +} diff --git a/src/Qiniu/Storage/BucketManager.php b/src/Qiniu/Storage/BucketManager.php index 40b7a9a7..51ec37dd 100644 --- a/src/Qiniu/Storage/BucketManager.php +++ b/src/Qiniu/Storage/BucketManager.php @@ -74,12 +74,13 @@ public function listbuckets( * * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error */ + public function createBucket($name, $region = 'z0') { $path = '/mkbucketv3/'.$name.'/region/' . $region; return $this->rsPost($path, null); } - + /** * 删除空间 * @@ -797,6 +798,24 @@ public function changeType($bucket, $key, $fileType) return $error; } + /** + * 修改指定资源的存储类型 + * + * @param $bucket 待操作资源所在空间 + * @param $key 待操作资源文件名 + * @param $day 解冻有效时长,取值范围 1~7 + * + * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error + * @link https://developer.qiniu.com/kodo/api/6380/restore-archive + */ + public function restoreFile($bucket, $key, $day) + { + $resource = \Qiniu\entry($bucket, $key); + $path = '/restoreAr/' . $resource . '/type/' . $day; + list(, $error) = $this->rsPost($path); + return $error; + } + /** * 修改文件的存储状态,即禁用状态和启用状态间的的互相转换 * From 855b2e1676788d102bfea16fdbd3aafd85af2773 Mon Sep 17 00:00:00 2001 From: anka <425732469@qq.com> Date: Thu, 19 Mar 2020 14:44:28 +0800 Subject: [PATCH 05/10] Update BucketManager.php --- src/Qiniu/Storage/BucketManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Qiniu/Storage/BucketManager.php b/src/Qiniu/Storage/BucketManager.php index 51ec37dd..d51d675d 100644 --- a/src/Qiniu/Storage/BucketManager.php +++ b/src/Qiniu/Storage/BucketManager.php @@ -80,7 +80,7 @@ public function createBucket($name, $region = 'z0') $path = '/mkbucketv3/'.$name.'/region/' . $region; return $this->rsPost($path, null); } - + /** * 删除空间 * @@ -811,7 +811,7 @@ public function changeType($bucket, $key, $fileType) public function restoreFile($bucket, $key, $day) { $resource = \Qiniu\entry($bucket, $key); - $path = '/restoreAr/' . $resource . '/type/' . $day; + $path = '/restoreAr/' . $resource . '/freezeAfterDays/' . $day; list(, $error) = $this->rsPost($path); return $error; } From 5f45abf6fad0a7564e80f0872c6a3818e72520c6 Mon Sep 17 00:00:00 2001 From: anka <425732469@qq.com> Date: Thu, 19 Mar 2020 16:18:38 +0800 Subject: [PATCH 06/10] Update BucketManager.php --- src/Qiniu/Storage/BucketManager.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Qiniu/Storage/BucketManager.php b/src/Qiniu/Storage/BucketManager.php index d51d675d..133c868e 100644 --- a/src/Qiniu/Storage/BucketManager.php +++ b/src/Qiniu/Storage/BucketManager.php @@ -71,7 +71,6 @@ public function listbuckets( * BucketName不满足以上要求返回400 (the specified bucket is not valid) * 如果BucketName已经被使用,返回614(bucket exists) * @param $region 创建的区域,默认华东 - * * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error */ From 335307371b0a6c612823f5a043196805c312a992 Mon Sep 17 00:00:00 2001 From: anka <425732469@qq.com> Date: Fri, 20 Mar 2020 09:53:20 +0800 Subject: [PATCH 07/10] Update BucketManager.php --- src/Qiniu/Storage/BucketManager.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Qiniu/Storage/BucketManager.php b/src/Qiniu/Storage/BucketManager.php index 133c868e..53eccc92 100644 --- a/src/Qiniu/Storage/BucketManager.php +++ b/src/Qiniu/Storage/BucketManager.php @@ -811,7 +811,7 @@ public function restoreFile($bucket, $key, $day) { $resource = \Qiniu\entry($bucket, $key); $path = '/restoreAr/' . $resource . '/freezeAfterDays/' . $day; - list(, $error) = $this->rsPost($path); + list(, $error) = $this->rsPostV2($path, null); return $error; } @@ -1030,6 +1030,12 @@ private function ucPostV2($path, $body) return $this->postV2($url, $body); } + private function rsPostV2($path, $body) + { + $url = $this->getRsHost() . $path; + return $this->postV2($url, $body); + } + private function postV2($url, $body) { $headers = $this->auth->authorizationV2($url, 'POST', $body, 'application/json'); From da8b3970f5f5ee6b965600af0ec5b3746feb6016 Mon Sep 17 00:00:00 2001 From: anka <425732469@qq.com> Date: Mon, 23 Mar 2020 08:50:48 +0800 Subject: [PATCH 08/10] Update BucketManager.php --- src/Qiniu/Storage/BucketManager.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Qiniu/Storage/BucketManager.php b/src/Qiniu/Storage/BucketManager.php index 53eccc92..b0acfe3c 100644 --- a/src/Qiniu/Storage/BucketManager.php +++ b/src/Qiniu/Storage/BucketManager.php @@ -803,7 +803,6 @@ public function changeType($bucket, $key, $fileType) * @param $bucket 待操作资源所在空间 * @param $key 待操作资源文件名 * @param $day 解冻有效时长,取值范围 1~7 - * * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error * @link https://developer.qiniu.com/kodo/api/6380/restore-archive */ From 557a3c91d8a4eeb179a0265d539ab08fcb076293 Mon Sep 17 00:00:00 2001 From: anka <425732469@qq.com> Date: Fri, 27 Mar 2020 15:05:25 +0800 Subject: [PATCH 09/10] Update BucketManager.php --- src/Qiniu/Storage/BucketManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Qiniu/Storage/BucketManager.php b/src/Qiniu/Storage/BucketManager.php index b0acfe3c..79b2422d 100644 --- a/src/Qiniu/Storage/BucketManager.php +++ b/src/Qiniu/Storage/BucketManager.php @@ -802,7 +802,7 @@ public function changeType($bucket, $key, $fileType) * * @param $bucket 待操作资源所在空间 * @param $key 待操作资源文件名 - * @param $day 解冻有效时长,取值范围 1~7 + * @param $day 解冻有效时长,取值范围 1~7,解冻存在等待时间 * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error * @link https://developer.qiniu.com/kodo/api/6380/restore-archive */ From df6c3c2973256da0eb19f8d2e92db5d554193926 Mon Sep 17 00:00:00 2001 From: timhbw Date: Wed, 5 Aug 2020 18:09:13 +0800 Subject: [PATCH 10/10] update readme --- README.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 16c8b49f..325f91bb 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,22 @@ # Qiniu Cloud SDK for PHP -[![doxygen.io](http://doxygen.io/github.com/qiniu/php-sdk/?status.svg)](http://doxygen.io/github.com/qiniu/php-sdk/) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) [![Build Status](https://travis-ci.org/qiniu/php-sdk.svg)](https://travis-ci.org/qiniu/php-sdk) +[![GitHub release](https://img.shields.io/github/v/tag/qiniu/php-sdk.svg?label=release)](https://github.com/qiniu/php-sdk/releases) [![Latest Stable Version](https://img.shields.io/packagist/v/qiniu/php-sdk.svg)](https://packagist.org/packages/qiniu/php-sdk) [![Total Downloads](https://img.shields.io/packagist/dt/qiniu/php-sdk.svg)](https://packagist.org/packages/qiniu/php-sdk) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/qiniu/php-sdk/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/qiniu/php-sdk/?branch=master) -[![Code Coverage](https://scrutinizer-ci.com/g/qiniu/php-sdk/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/qiniu/php-sdk/?branch=master) +[![Coverage Status](https://codecov.io/gh/qiniu/php-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/php-sdk) [![Join Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/qiniu/php-sdk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![@qiniu on weibo](http://img.shields.io/badge/weibo-%40qiniutek-blue.svg)](http://weibo.com/qiniutek) + ## 安装 -* 通过composer,这是推荐的方式,可以使用composer.json 声明依赖,或者运行下面的命令。SDK 包已经放到这里 [`qiniu/php-sdk`][install-packagist] 。 +* 推荐使用 `composer` 进行安装。可以使用 composer.json 声明依赖,或者运行下面的命令。SDK 包已经放到这里 [`qiniu/php-sdk`][install-packagist] 。 ```bash $ composer require qiniu/php-sdk ``` -* 直接下载安装,SDK 没有依赖其他第三方库,但需要参照 composer的autoloader,增加一个自己的autoloader程序。 +* 直接下载安装,SDK 没有依赖其他第三方库,但需要参照 composer 的 autoloader,增加一个自己的 autoloader 程序。 ## 运行环境 @@ -31,10 +32,10 @@ $ composer require qiniu/php-sdk use Qiniu\Storage\UploadManager; use Qiniu\Auth; ... - $upManager = new UploadManager(); + $uploadMgr = new UploadManager(); $auth = new Auth($accessKey, $secretKey); - $token = $auth->uploadToken($bucketName); - list($ret, $error) = $upManager->put($token, 'formput', 'hello world'); + $token = $auth->uploadToken($bucket); + list($ret, $error) = $uploadMgr->putFile($token, 'key', 'filePath'); ... ``` @@ -46,7 +47,7 @@ $ ./vendor/bin/phpunit tests/Qiniu/Tests/ ## 常见问题 -- $error保留了请求响应的信息,失败情况下ret 为none, 将$error可以打印出来,提交给我们。 +- `$error` 保留了请求响应的信息,失败情况下 `ret` 为 `none`, 将 `$error` 可以打印出来,提交给我们。 - API 的使用 demo 可以参考 [单元测试](https://github.com/qiniu/php-sdk/blob/master/tests)。 ## 代码贡献 @@ -60,12 +61,12 @@ $ ./vendor/bin/phpunit tests/Qiniu/Tests/ ## 联系我们 - 如果需要帮助,请提交工单(在portal右侧点击咨询和建议提交工单,或者直接向 support@qiniu.com 发送邮件) -- 如果有什么问题,可以到问答社区提问,[问答社区](http://qiniu.segmentfault.com/) -- 更详细的文档,见[官方文档站](http://developer.qiniu.com/) -- 如果发现了bug, 欢迎提交 [issue](https://github.com/qiniu/php-sdk/issues) +- 如果有什么问题,可以到问答社区提问,[问答社区](https://qiniu.segmentfault.com/) +- 更详细的文档,见[官方文档站](https://developer.qiniu.com/) +- 如果发现了 bug, 欢迎提交 [issue](https://github.com/qiniu/php-sdk/issues) - 如果有功能需求,欢迎提交 [issue](https://github.com/qiniu/php-sdk/issues) - 如果要提交代码,欢迎提交 pull request -- 欢迎关注我们的[微信](http://www.qiniu.com/#weixin) [微博](http://weibo.com/qiniutek),及时获取动态信息。 +- 欢迎关注我们的[微信](https://www.qiniu.com/#weixin) [微博](https://weibo.com/qiniutek),及时获取动态信息。 ## 代码许可