liuzejian 2 éve
commit
f92dbe8241
100 módosított fájl, 19925 hozzáadás és 0 törlés
  1. 18 0
      .editorconfig
  2. 72 0
      .env.example
  3. 11 0
      .gitattributes
  4. 24 0
      .gitee/ISSUE_TEMPLATE.zh-CN.md
  5. 25 0
      .github/issue_template.md
  6. 28 0
      .gitignore
  7. 101 0
      .php-cs-fixer.dist.php
  8. 10 0
      .prettierrc
  9. 199 0
      LICENSE.txt
  10. 24 0
      README.md
  11. 108 0
      app/Console/Commands/ContentManage/BookCopyrightAlert.php
  12. 105 0
      app/Console/Commands/ContentManage/BookImport.php
  13. 32 0
      app/Console/Commands/ContentManage/ContentTest.php
  14. 91 0
      app/Console/Commands/ContentManage/CpSubscribeMonthStatisticData.php
  15. 59 0
      app/Console/Commands/ContentManage/NewCpBookComeIn.php
  16. 100 0
      app/Console/Commands/ContentManage/SaveBookSettlementMode.php
  17. 38 0
      app/Console/Commands/ContentManage/SyncCpSubscribeStatisticDataFromZW.php
  18. 144 0
      app/Console/Commands/ContentManage/cpCollection.php
  19. 56 0
      app/Console/Kernel.php
  20. 33 0
      app/Events/Create.php
  21. 33 0
      app/Events/Test.php
  22. 85 0
      app/Exceptions/Handler.php
  23. 13 0
      app/Http/Controllers/Controller.php
  24. 67 0
      app/Http/Kernel.php
  25. 21 0
      app/Http/Middleware/Authenticate.php
  26. 17 0
      app/Http/Middleware/EncryptCookies.php
  27. 17 0
      app/Http/Middleware/PreventRequestsDuringMaintenance.php
  28. 32 0
      app/Http/Middleware/RedirectIfAuthenticated.php
  29. 19 0
      app/Http/Middleware/TrimStrings.php
  30. 20 0
      app/Http/Middleware/TrustHosts.php
  31. 28 0
      app/Http/Middleware/TrustProxies.php
  32. 22 0
      app/Http/Middleware/ValidateSignature.php
  33. 17 0
      app/Http/Middleware/VerifyCsrfToken.php
  34. 345 0
      app/Libs/Helpers.php
  35. 35 0
      app/Libs/HuaweiObsSdk/Help on License
  36. 219 0
      app/Libs/HuaweiObsSdk/LICENSE
  37. 39 0
      app/Libs/HuaweiObsSdk/Notice.MD
  38. 63 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Common/CheckoutStream.php
  39. 23 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Common/ITransform.php
  40. 257 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Common/Model.php
  41. 78 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Common/ObsTransform.php
  42. 116 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Common/SchemaFormatter.php
  43. 430 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Common/SdkCurlFactory.php
  44. 519 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Common/SdkStreamHandler.php
  45. 23 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Common/ToArrayInterface.php
  46. 83 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Common/V2Transform.php
  47. 455 0
      app/Libs/HuaweiObsSdk/Obs/Internal/GetResponseTrait.php
  48. 123 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Resource/Constants.php
  49. 35 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Resource/OBSConstants.php
  50. 4202 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Resource/OBSRequestResource.php
  51. 38 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Resource/V2Constants.php
  52. 4020 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Resource/V2RequestResource.php
  53. 726 0
      app/Libs/HuaweiObsSdk/Obs/Internal/SendRequestTrait.php
  54. 471 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Signature/AbstractSignature.php
  55. 138 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Signature/DefaultSignature.php
  56. 25 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Signature/SignatureInterface.php
  57. 199 0
      app/Libs/HuaweiObsSdk/Obs/Internal/Signature/V4Signature.php
  58. 28 0
      app/Libs/HuaweiObsSdk/Obs/Log/ObsConfig.php
  59. 126 0
      app/Libs/HuaweiObsSdk/Obs/Log/ObsLog.php
  60. 415 0
      app/Libs/HuaweiObsSdk/Obs/ObsClient.php
  61. 140 0
      app/Libs/HuaweiObsSdk/Obs/ObsException.php
  62. 32 0
      app/Libs/HuaweiObsSdk/README.md
  63. 19 0
      app/Libs/HuaweiObsSdk/composer.json
  64. 503 0
      app/Libs/HuaweiObsSdk/examples/BucketOperationsSample.php
  65. 221 0
      app/Libs/HuaweiObsSdk/examples/ConcurrentCopyPartSample.php
  66. 203 0
      app/Libs/HuaweiObsSdk/examples/ConcurrentDownloadObjectSample.php
  67. 215 0
      app/Libs/HuaweiObsSdk/examples/ConcurrentUploadPartSample.php
  68. 100 0
      app/Libs/HuaweiObsSdk/examples/CreateFolderSample.php
  69. 149 0
      app/Libs/HuaweiObsSdk/examples/DeleteObjectsSample.php
  70. 101 0
      app/Libs/HuaweiObsSdk/examples/DownloadSample.php
  71. 191 0
      app/Libs/HuaweiObsSdk/examples/ListObjectsInFolderSample.php
  72. 180 0
      app/Libs/HuaweiObsSdk/examples/ListObjectsSample.php
  73. 236 0
      app/Libs/HuaweiObsSdk/examples/ListVersionsSample.php
  74. 107 0
      app/Libs/HuaweiObsSdk/examples/ObjectMetaSample.php
  75. 187 0
      app/Libs/HuaweiObsSdk/examples/ObjectOperationsSample.php
  76. 1406 0
      app/Libs/HuaweiObsSdk/examples/ObsPhpDemo.php
  77. 227 0
      app/Libs/HuaweiObsSdk/examples/PostObjectSample.php
  78. 110 0
      app/Libs/HuaweiObsSdk/examples/RestoreObjectSample.php
  79. 109 0
      app/Libs/HuaweiObsSdk/examples/SimpleMultipartUploadSample.php
  80. 151 0
      app/Libs/HuaweiObsSdk/examples/TemporarySignatureSample.php
  81. 34 0
      app/Libs/HuaweiObsSdk/obs-autoloader.php
  82. 30 0
      app/Listeners/Command.php
  83. 28 0
      app/Listeners/RouteMatched.php
  84. 27 0
      app/Listeners/test.php
  85. 11 0
      app/Models/Modules/Users/Models/CatchController.php
  86. 45 0
      app/Models/User.php
  87. 28 0
      app/Providers/AppServiceProvider.php
  88. 30 0
      app/Providers/AuthServiceProvider.php
  89. 21 0
      app/Providers/BroadcastServiceProvider.php
  90. 53 0
      app/Providers/EventServiceProvider.php
  91. 62 0
      app/Providers/RouteServiceProvider.php
  92. 53 0
      artisan
  93. 1 0
      blaze/config/blaze.php
  94. 3 0
      blaze/resources/views/components/navigate.blade.php
  95. 1 0
      blaze/resources/views/components/paginate.blade.php
  96. 1 0
      blaze/src/BlazeServiceProvider.php
  97. 1 0
      blaze/src/Components/Navigate.php
  98. 1 0
      blaze/src/Components/Paginate.php
  99. 8 0
      blaze/src/Contracts/DirectiveContract.php
  100. 0 0
      blaze/src/Directives/Post.php

+ 18 - 0
.editorconfig

@@ -0,0 +1,18 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.{yml,yaml}]
+indent_size = 2
+
+[docker-compose.yml]
+indent_size = 4

+ 72 - 0
.env.example

@@ -0,0 +1,72 @@
+APP_NAME=内容中台管理系统
+APP_ENV=local
+APP_KEY=base64:XPnLY2xN9IJdf3RvrEuz83kU119Vl+JW+BAe0G04AjI=
+APP_DEBUG=true
+APP_URL=http://api.zynrzt.com
+
+LOG_CHANNEL=stack
+LOG_DEPRECATIONS_CHANNEL=null
+LOG_LEVEL=debug
+
+DB_CONNECTION=mysql
+DB_HOST=121.37.176.94
+DB_PORT=3306
+DB_DATABASE=test_zy_book_content
+DB_USERNAME=otestzy_wzq
+DB_PASSWORD=zy_wzq2023%2023
+DB_PREFIX=zy_
+
+BROADCAST_DRIVER=log
+CACHE_DRIVER=file
+FILESYSTEM_DISK=local
+QUEUE_CONNECTION=sync
+SESSION_DRIVER=file
+SESSION_LIFETIME=120
+
+MEMCACHED_HOST=127.0.0.1
+
+REDIS_HOST=127.0.0.1
+REDIS_PASSWORD=null
+REDIS_PORT=6379
+
+MAIL_MAILER=smtp
+MAIL_HOST=mailhog
+MAIL_PORT=1025
+MAIL_USERNAME=null
+MAIL_PASSWORD=null
+MAIL_ENCRYPTION=null
+MAIL_FROM_ADDRESS="hello@example.com"
+MAIL_FROM_NAME="${APP_NAME}"
+
+AWS_ACCESS_KEY_ID=
+AWS_SECRET_ACCESS_KEY=
+AWS_DEFAULT_REGION=us-east-1
+AWS_BUCKET=
+AWS_USE_PATH_STYLE_ENDPOINT=false
+
+PUSHER_APP_ID=
+PUSHER_APP_KEY=
+PUSHER_APP_SECRET=
+PUSHER_HOST=
+PUSHER_PORT=443
+PUSHER_SCHEME=https
+PUSHER_APP_CLUSTER=mt1
+
+VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
+VITE_PUSHER_HOST="${PUSHER_HOST}"
+VITE_PUSHER_PORT="${PUSHER_PORT}"
+VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
+VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
+VITE_BASE_URL=${APP_URL}/api/
+VITE_APP_NAME=${APP_NAME}
+
+ALIOSS_BUCKET=
+ALIOSS_ACCESS_ID=
+ALIOSS_ACCESS_SECRET=
+ALIOSS_ENDPOINT=
+ALIOSS_UPLOAD_DIR=
+
+#public接口域名
+PUBLIC_DOMAIN=https://pubapi.pre.aizhuishu.com
+#加密秘钥
+EXTERNAL_PRIVATE_KEY=ZSY_2021!KEY

+ 11 - 0
.gitattributes

@@ -0,0 +1,11 @@
+* text=auto
+
+*.blade.php diff=html
+*.css diff=css
+*.html diff=html
+*.md diff=markdown
+*.php diff=php
+
+/.github export-ignore
+CHANGELOG.md export-ignore
+.styleci.yml export-ignore

+ 24 - 0
.gitee/ISSUE_TEMPLATE.zh-CN.md

@@ -0,0 +1,24 @@
+# 环境
+- 操作系统:
+- php 版本:
+- Laravel 版本:
+- Mysql 版本:
+- web 服务器:
+
+# 问题
+- 问题描述:
+- 问题截图:
+
+# 结果
+- 实际结果:
+- 预期结果:
+
+# 分析
+- 所做的尝试:
+    -
+    -
+
+# 方案:
+- 解决方案:
+
+> 请在问题解决后关闭 issue

+ 25 - 0
.github/issue_template.md

@@ -0,0 +1,25 @@
+# 环境
+- 操作系统:
+- php 版本:
+- Laravel 版本:
+- Mysql 版本:
+- web 服务器:
+
+# 问题
+- 问题描述:
+
+- 问题截图:
+
+# 结果
+- 实际结果:
+- 预期结果:
+
+# 分析
+- 所做的尝试:
+    -
+    -
+
+# 方案:
+- 解决方案:
+
+> 请在问题解决后关闭 issue

+ 28 - 0
.gitignore

@@ -0,0 +1,28 @@
+/node_modules
+/public/build
+/public/hot
+/public/storage
+/storage/*.key
+/vendor
+/fixer
+/catch
+.env
+.env.backup
+.env.production
+.phpunit.result.cache
+.php-cs-fixer.cache
+Homestead.json
+Homestead.yaml
+auth.json
+npm-debug.log
+yarn-error.log
+yarn.lock
+composer.lock
+/.fleet
+/.idea
+/.vscode
+components.d.ts
+auto-imports.d.ts
+.DS_Store
+/bootstrap/cache
+/node_modules

+ 101 - 0
.php-cs-fixer.dist.php

@@ -0,0 +1,101 @@
+<?php
+
+require_once __DIR__.DIRECTORY_SEPARATOR.'fixer'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
+
+use PhpCsFixer\Finder;
+use PhpCsFixer\Config;
+
+$finder = Finder::create()
+    // 排除目录
+    //->exclude('packages')
+    //// ->notPath('./packages/test.php')
+    // in 配置需要规则的目录
+    ->in([
+        __DIR__.DIRECTORY_SEPARATOR.'app',
+
+        __DIR__.DIRECTORY_SEPARATOR.'catch',
+
+        __DIR__.DIRECTORY_SEPARATOR.'modules',
+    ])
+    // 排除 . 开头的文件
+    ->ignoreDotFiles(true)
+    // vcs 文件
+    ->ignoreVCS(true);
+
+$config = new Config();
+
+return $config->setRules([
+    '@PSR1' => true, // psr1
+
+    '@PSR2' => true, //  psr2 规范
+
+    '@PSR12' => true, // psr12 规范
+
+    'binary_operator_spaces' => true, // 二元操作符号空格 $a=1 => $a = 1;
+
+    'array_syntax' => [
+        'syntax' => 'short', // array('1') => ['1']
+    ],
+
+    'no_trailing_comma_in_singleline_array' => true, // -$a = array('sample',  ); => $a = array('sample');
+
+    'trim_array_spaces' => true, // array( 'a', 'b' ); => array('a', 'b')
+
+    'single_trait_insert_per_statement' => false,
+
+    'standardize_not_equals' => true, // "!=" => "<>"
+
+    'magic_constant_casing' => true, // __dir__ => __DIR__
+
+    'native_function_casing' => true, // STRLEN($str); => strlen($str);
+
+    'cast_spaces' => true, // (int)$b => (int) $b
+
+    'simplified_if_return' => true, // if ($foo) { return true; } return false; => return (bool) ($foo)      ;
+
+    'no_unused_imports' => true, //  use \DateTime; -use \Exception; => use \DateTime;
+
+    'not_operator_with_successor_space' => true, // if (!$bar)  => if (! $bar)
+
+    /**
+     * // function example($b) {
+    if ($b) {
+    return;
+    }
+    - return;
+     */
+    'no_useless_return' => true,
+
+    /**
+     * function a() {
+    -    $a = 1;
+    -    return $a;
+    +    return 1;
+     */
+    'return_assignment' => true,
+
+    /**
+    -<?php return null;
+    +<?php return;
+     */
+    'simplified_null_return' => true,
+
+    /**
+     * $foo = [
+    -   'bar' => [
+    -    'baz' => true,
+    -  ],
+    +    'bar' => [
+    +        'baz' => true,
+    +    ],
+     */
+    'array_indentation' => true,
+
+    /**
+     * -$sample = $b [ 'a' ] [ 'b' ];
+    +$sample = $b['a']['b'];
+     */
+    'no_spaces_around_offset' => true,
+
+    'concat_space' => true,  // $a.$b => $a . $b
+])->setFinder($finder);

+ 10 - 0
.prettierrc

@@ -0,0 +1,10 @@
+{
+  "semi": false,
+  "printWidth": 200,
+  "tabWidth": 2,
+  "useTabs": false,
+  "singleQuote": true,
+  "arrowParens": "avoid",
+  "trailingComma": "all",
+  "bracketSpacing": true
+}

+ 199 - 0
LICENSE.txt

@@ -0,0 +1,199 @@
+ Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

+ 24 - 0
README.md

@@ -0,0 +1,24 @@
+开发必读
+本系统基于catchadmin 开发
+文档地址:https://catchadmin.com/docs/3.0
+
+开发前安装: 
+安装vendor composer install
+开发不需执行php artisan catch:install,只需要把.env.example 复制为:.evn 即可。
+#注意:
+    1.开发是需要安装 权限模块 执行命令 php artisan catch:module:install permissions 
+    2.本地开发查看 storage/app/modules.json 如未发现该文件,或者在文件没为找到木块对应的名称,则需要执行 php artisan catch:module:install + 模块名 的命令
+    使用时需要安装模块,否则会提示找不到路由,安装命令如下:
+    php artisan catch:module:install + 模块名 
+
+
+#开发约定:
+    内容中台开发模块为:contentManage
+    开发是需要阅读路劲为:modules/ContentManage/README.md的文档文件
+    权限模块:permissions  暂时不需开发
+    基础模块: Common 目前主只有上传文件的功能
+    脚本目录为: app/Console 各模块在app/Console目录下创建以模块名命名的文件夹下面。如需再分层则在其目录下创建对应文件目录
+
+
+#强烈注意:
+    在使用laravel 队列时候 不允许使用  laravel 本身自带的延迟队里方法 delay

+ 108 - 0
app/Console/Commands/ContentManage/BookCopyrightAlert.php

@@ -0,0 +1,108 @@
+<?php
+
+namespace App\Console\Commands\ContentManage;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
+use Modules\ContentManage\Services\Notice\NoticesService;
+
+class BookCopyrightAlert extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'ContentManage:BookCopyrightAlert';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '书籍版权快到期预警';
+    private $alertDate;
+    /**
+     * Execute the console command.
+     */
+    public function handle(): void
+    {
+        $todayStr = date('Y-m-d');
+        $alertDate = date_add(date_create($todayStr), date_interval_create_from_date_string('30 day'))->format('Y-m-d');
+        $roleIds = DB::table('roles')
+            ->whereIn('identify', ['admin', 'businessmaster', 'business'])
+            ->where('deleted_at', '=', 0)
+            ->select('id')
+            ->get()->pluck('id')->unique();
+        $users = DB::table('users')->join('user_has_roles', 'users.id', 'user_has_roles.user_id')
+            ->whereIn('user_has_roles.role_id', $roleIds)
+            ->where('users.deleted_at', '=', 0)
+            ->where('users.status', '=', 1)
+            ->select('id', 'username', 'email')
+            ->get()->keyBy('id');
+        DB::table('books')
+            ->where('end_date', '<>', '')
+            ->where('end_date', '<=', $alertDate)
+            ->orderBy('id', 'desc')
+            ->select('id','name', 'start_date', 'end_date', 'cp_name', 'cp_id')
+            ->chunk(300, function ($books) use ($users, $todayStr){
+                    foreach ($books->chunk(30) as $iBooks) {
+                        $this->copyrightAlert($iBooks, $users, $todayStr);
+                    }
+            });
+    }
+
+
+    /**
+     * 快到期书籍,邮件通知,内容管理后台消息通知
+     * @param $iBooks
+     * @param $userCollect
+     */
+    private function copyrightAlert($iBooks, $userCollect, $todayStr) {
+        $emailStr = '';
+        $noticeStr = '';
+        foreach ($iBooks as $book) {
+            $leftDay = intval(date_diff(date_create($todayStr), date_create($book->end_date))->format("%r%a"));
+            if($leftDay > 0) {
+                $emailStr .= 'bid='.$book->id. "<br>";
+                $emailStr .= '书名='.$book->name. "<br>";
+                $emailStr .= '版权开始日期='.$book->start_date. "<br>";
+                $emailStr .= '版权结束日期='.$book->end_date. "<br>";
+                $emailStr .= '版权剩余天数='. $leftDay . "天<br>";
+                $emailStr .= 'cp_name='.$book->cp_name. "<br>";
+                $emailStr .= 'cp_id='.$book->cp_id. "<br>";
+                $emailStr .= "==========================================<br>";
+            } else {
+                $noticeStr .= 'bid='.$book->id. "<br>";
+                $noticeStr .= '书名='.$book->name. "<br>";
+                $noticeStr .= '版权开始日期='.$book->start_date. "<br>";
+                $noticeStr .= '版权结束日期='.$book->end_date. "<br>";
+                $noticeStr .= 'cp_name='.$book->cp_name. "<br>";
+                $noticeStr .= 'cp_id='.$book->cp_id. "<br>";
+                $noticeStr .= "==========================================<br>";
+            }
+
+        }
+
+
+        $users = [];
+        foreach ($userCollect as $user) {
+            $users[] = ['address' => $user->email, 'name' => $user->username];
+        }
+
+
+        $params = [
+            'subject' => sprintf('版权快到期预警[%s]', date('Y-m-d H:i:s')),
+            'body' => $emailStr
+        ];
+        sendEmail($users,$params);
+
+        NoticesService::addNotice([
+            'title' => '书籍版权到期提醒',
+            'notice_type_id' => 2,
+            'type' => 1,
+            'is_popup' => 1,
+            'content' => $noticeStr
+        ]);
+    }
+}

+ 105 - 0
app/Console/Commands/ContentManage/BookImport.php

@@ -0,0 +1,105 @@
+<?php
+
+namespace App\Console\Commands\ContentManage;
+
+use Illuminate\Console\Command;
+use Modules\ContentManage\Models\BookCategories;
+use Modules\ContentManage\Models\Cp\Cps;
+use Modules\ContentManage\Services\Books\BooksService;
+use Modules\ContentManage\Services\Books\ChapterService;
+
+class BookImport extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'ContentManage:bookimport {--name=: 书名}
+                                                     {--cp_id=:cp_id}
+                                                     {--category_id=:分类id}
+                                                     {--author=:作者}
+                                                     {--vip=:vip起始章节默认:8}
+                                                     {--filename=:文件名,放在storage/app/目录下}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '导入书籍文本';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle(): void
+    {
+        $create_info = $this->createBook();
+        if($create_info['error']){
+            return ;
+        }
+        $filname = $this->option('filename');
+        if(!$filname){
+            $this->error('filename empty');
+            return ;
+        }
+        $result = $create_info['book'];
+        $chapter_result = $this->createChapter( $result->id,$filname);
+        $result->size = $chapter_result['size'];
+        $result->chapter_count = $chapter_result['chapter_count'];
+        $result->first_cid = $chapter_result['first_cid'];
+        $result->last_cid = $chapter_result['last_cid'];
+        $result->last_chapter = $chapter_result['last_chapter'];
+        $result->save();
+    }
+
+
+    private function createBook(){
+        $cp_id = $this->option('cp_id');
+        $book_name = $this->option('name');
+        $author  = $this->option('author');
+        $category_id = $this->option('category_id');
+        $cp_name = $this->getCpName($cp_id);
+        if(!$cp_name){
+            $this->error('cp_id不存在');
+            return ['error'=>1];
+        }
+
+        $category_info = $this->getCategoryInfo($category_id);
+        if(!$category_info){
+            $this->error('分类id不存在');
+            return ['error'=>2];
+        }
+
+        $result = BooksService::createBook([
+            'cp_name'=>$cp_name,'cp_id'=>$cp_id,'name'=>$book_name,'author'=>$author ?? '','intro'=>'','cover'=>'','category_id'=>$category_id,
+            'category_name'=>$category_info->category_name,'status'=>1,'channel'=>$category_info->channel_id
+        ]);
+        if(!$result){
+            $this->error('已经存在了');
+            return ['error'=>3];
+        }
+        return ['error'=>0,'book'=>$result];
+    }
+
+    private function createChapter($bid,$filname){
+        $vip_start = $this->option('vip');
+        $path = storage_path('app/'.$filname);
+        return  ChapterService::createChapterFromFile($bid,1,$vip_start ?? 8,$path);
+    }
+
+
+    private function getCpName($cp_id){
+        $cp_info = Cps::where('cp_id',$cp_id)->select('cp_nick')->first();
+        if($cp_info){
+            return $cp_info->cp_nick;
+        }
+        return '';
+    }
+
+
+    private function getCategoryInfo($category_id){
+        return BookCategories::where('id',$category_id)->first();
+    }
+
+}

+ 32 - 0
app/Console/Commands/ContentManage/ContentTest.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Console\Commands\ContentManage;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Redis;
+
+class ContentTest extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'app:contenttest';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Command description';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle(): void
+    {
+        Redis::set('test-aa', 1132412);
+        $this->info(Redis::get('test-aa'));
+    }
+}

+ 91 - 0
app/Console/Commands/ContentManage/CpSubscribeMonthStatisticData.php

@@ -0,0 +1,91 @@
+<?php
+
+namespace App\Console\Commands\ContentManage;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
+use Modules\Common\Support\Trace\TraceContext;
+use Modules\ContentManage\Services\CpManage\BookSettlement;
+
+class CpSubscribeMonthStatisticData extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'ContentManage:CpSubscribeMonthStatisticData {--month= : 被统计的月份}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'cp订阅数据月统计';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle(): void
+    {
+        $month = $this->option('month');
+        if(!$month){
+            $this->error('month necessary');
+        }
+
+        $cpNames = DB::table('cps')
+            ->select('cp_name')
+            ->get()->pluck('cp_name');
+
+        $datas = DB::table('cp_subscribe_statistic_data')
+            ->where([
+                'month' => $month
+            ])->select(
+                DB::raw('count(distinct bid) as book_num'),
+                'cp_name'
+            )->groupBy('cp_name')
+            ->get()->keyBy('cp_name');
+
+        $insertDatas = [];
+        $now = date('Y-m-d H:i:s');
+        foreach ($cpNames as $cpName) {
+            $bookFinalAmounts = [];
+            $bids = DB::table('cp_subscribe_statistic_data')
+                ->where(['cp_name' => $cpName, 'month' => $month])
+                ->distinct()
+                ->select('bid')
+                ->get()->pluck('bid');
+            $finalAmount = 0;
+            DB::table('cp_book_month_final_amounts')
+                ->where(['cp_name' => $cpName, 'month' => $month])
+                ->update(['is_enabled' => 0, 'updated_at' => $now]);
+            foreach ($bids as $bid) {
+                $service = new BookSettlement($bid, $month);
+                $service->traceContext = TraceContext::newFromParent(app(TraceContext::class)->getTraceInfo());
+                $bookFinalAmountDetails = $service->detail();
+                $monthFinalAmount = array_sum($bookFinalAmountDetails);
+                $finalAmount += $monthFinalAmount;
+                $bookFinalAmounts[] = [
+                    'bid' => $bid,
+                    'cp_name' => $cpName,
+                    'month' => $month,
+                    'final_amount' => $monthFinalAmount,
+                    'created_at' => $now,
+                    'updated_at' => $now,
+                ];
+            }
+
+            DB::table('cp_book_month_final_amounts')
+                ->insert($bookFinalAmounts);
+
+            $insertDatas[] = [
+                'book_num' => $datas->get($cpName)->book_num ?? 0, 'final_amount' => $finalAmount,
+                'cp_name' => $cpName, 'month' => $month, 'created_at' => $now, 'updated_at' => $now,
+            ];
+        }
+
+        DB::table('cp_subscribe_month_statistic_data')
+            ->insert($insertDatas);
+    }
+
+}

+ 59 - 0
app/Console/Commands/ContentManage/NewCpBookComeIn.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace App\Console\Commands\ContentManage;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Redis;
+use Modules\ContentManage\Services\Notice\NoticesService;
+
+class NewCpBookComeIn extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'ContentManage:NewCpBookComeIn';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '如果发现当天有cp方新的书籍接入进来后,自动生成公告通知';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle(): void
+    {
+        $datetime = date_sub(date_create(), date_interval_create_from_date_string('28 hour'))->format('Y-m-d H:i:s');
+        $books = DB::table('books')
+            ->where('created_at', '>=', $datetime)
+            ->select('id', 'cp_name', 'name')
+            ->get();
+        $redisKey = 'contentManage.cp.newBook.alreadyAlert';
+        $str = '';
+        foreach ($books as $book) {
+            if(Redis::sismember($redisKey, $book->id)) {
+                continue;
+            }
+            $str .= sprintf('%s cp方的新书:%s <br>', $book->cp_name, $book->name);
+            Redis::sadd($redisKey, $book->id);
+        }
+        if(!$str) {
+            return ;
+        }
+
+        $str .= '已经进入植宇内容中台,请尽快查看';
+
+        NoticesService::addNotice([
+            'title' => '有cp方新的书籍接入',
+            'notice_type_id' => 2,
+            'type' => 1,
+            'is_popup' => 1,
+            'content' => $str
+        ]);
+    }
+}

+ 100 - 0
app/Console/Commands/ContentManage/SaveBookSettlementMode.php

@@ -0,0 +1,100 @@
+<?php
+
+namespace App\Console\Commands\ContentManage;
+
+use Dotenv\Store\StoreBuilder;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
+
+class SaveBookSettlementMode extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'ContentManage:SaveBookSettlementMode {--bid= : 书籍id}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '保存书籍的结算模式,每天执行一次';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle(): void
+    {
+        $maxBid = 0;
+        $bid = $this->option('bid');
+        while (true) {
+            $books = DB::table('books')
+                ->when($bid, function ($query, $bid) {
+                    return $query->where(['id' => $bid]);
+                })
+                ->select('id', 'settlement_type', 'bottomline')
+                ->orderBy('id', 'asc')
+                ->where('id', '>', $maxBid)
+                ->limit(300)
+                ->get();
+            $maxBid = $books->last()->id ?? 0;
+            if(0 == $maxBid) {
+                break;
+            }
+            $this->dealBooks($books);
+        }
+    }
+
+    private function dealBooks($books) {
+        $nowDate = date('Y-m-d');
+        $nowTime = date('Y-m-d H:i:s');
+        $bids = $books->pluck('id')->unique();
+        $bookLasteSettlementModeMap = $this->bookLasteSettlementModeMap($bids);
+        foreach ($books as $book) {
+            if($bookLasteSettlementModeMap->has($book->id)) {
+                $bookLasteSettlementMode = $bookLasteSettlementModeMap->get($book->id);
+                if($book->settlement_type == $bookLasteSettlementMode['settlement_mode'] &&
+                    $book->bottomline == $bookLasteSettlementMode['bottomline']) {
+                    continue;
+                }
+            }
+            DB::table('book_settlement_mode_history')
+                ->insert([
+                    'bid' => $book->id,
+                    'effective_date' => $nowDate,
+                    'settlement_mode' => $book->settlement_type,
+                    'bottomline' => $book->bottomline,
+                    'change_reason' => 'manual',
+                    'created_at' => $nowTime,
+                    'updated_at' => $nowTime
+                ]);
+        }
+    }
+
+    private function bookLasteSettlementModeMap($bids) {
+        $map = collect();
+        $history = DB::table('book_settlement_mode_history')
+            ->whereIn('bid', $bids)
+            ->where([
+                'is_enabled' => 1, 'change_reason' => 'manual'
+            ])->select('id', 'settlement_mode', 'bottomline', 'effective_date', 'bid')
+            ->orderBy('id', 'desc')
+            ->get();
+        foreach ($history as $h) {
+            if($map->has($h->bid)) {
+                $settlementMode = $map->get($h->bid);
+                if($settlementMode['effective_date'] >= $h->effective_date) {
+                    continue;
+                }
+            }
+            $map->put($h->bid, [
+                'effective_date' => $h->effective_date,
+                'settlement_mode' => $h->settlement_mode,
+                'bottomline' => $h->bottomline
+            ]);
+        }
+        return $map;
+    }
+}

+ 38 - 0
app/Console/Commands/ContentManage/SyncCpSubscribeStatisticDataFromZW.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Console\Commands\ContentManage;
+
+use Illuminate\Console\Command;
+use Modules\ContentManage\Services\CpManage\SyncSubscribe;
+
+class SyncCpSubscribeStatisticDataFromZW extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'ContentManage:SyncCpSubscribeStatisticDataFromZW {--startDate= : 开始日期如2023-03-01}
+                                                                             {--endDate= : 结束日期如2023-03-02}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '从掌维拉取cp书籍订阅数据';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle(): void
+    {
+        $startDate = $this->option('startDate');
+        $endDate = $this->option('endDate');
+
+        $syncService = new SyncSubscribe();
+        $syncService->syncStartDate = $startDate;
+        $syncService->syncEndDate = $endDate;
+        $syncService->sync();
+    }
+}

+ 144 - 0
app/Console/Commands/ContentManage/cpCollection.php

@@ -0,0 +1,144 @@
+<?php
+
+namespace App\Console\Commands\ContentManage;
+
+use Illuminate\Console\Command;
+use Modules\ContentManage\Models\Cp\CpCollection as CpCollectionModel;
+use Modules\ContentManage\Models\Book;
+use Illuminate\Support\Facades\Process;
+use Modules\ContentManage\Services\Notice\NoticesService;
+use Modules\Permissions\Models\Roles;
+use Log;
+
+
+class cpCollection extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'ContentManage:cpcollection';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Command description';
+
+    private $cp_name = '';
+    private $spider_name = '';
+    private $cp_id = 0;
+    private $commad_status = -1;
+    private $start_time;
+
+    private $record = null;
+
+
+
+    public function __construct(protected readonly CpCollectionModel $CpCollectionModel,protected readonly Book $book)
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     */
+    public function handle(): void
+    {
+        $this->getTask();
+        if(!$this->cp_id){
+            return ;
+        }
+        $this->start_time = date('Y-m-d H:i:s');
+        $this->runSpider();
+        if($this->commad_status){
+            $this->record->spider_status = 3;
+        }else{
+            $this->record->spider_status = 2;
+        }
+        $spider_result = $this->getResult();
+        $this->record->spider_result = $spider_result->pluck('id')->implode(',');
+        $this->record->save();
+        $this->notice($spider_result);
+    }
+
+    /**
+     * 获取同步任务,一次只获取一个
+     * @return void
+     */
+    private function getTask(){
+        $record = $this->CpCollectionModel->where('created_at','>',date('Y-m-d H:i:s',time()-86400))->where('spider_status',0)->first();
+        if($record){
+            $record->spider_status = 1;
+            $record->save();
+            $this->cp_name = $record->cp_name; 
+            $this->cp_id = $record->cp_id;
+            $this->spider_name = str_replace('zy_','',$this->cp_name);
+            $this->record = $record;
+        }
+    }
+
+
+    /**
+     * 执行脚本,并获取状态
+     * @return void
+     */
+    private function runSpider(){
+        $command = ' bash /project/www/zhiyu_content_spider/content_spider/bash/command.sh '.$this->spider_name;
+        Log::info('cpCollection',['command'=>$command]);
+        $result = Process::forever()->run($command);
+        if($result->successful()){
+            $this->commad_status = 0;
+        }else{
+            $this->commad_status = 1;
+        }
+    }
+
+    /**
+     * 获取同步结果
+     */
+    private function getResult(){
+       return  $this->book->where('cp_id',$this->cp_id)
+        ->where('created_at','>=',$this->start_time)
+        ->where('created_at','<=',date('Y-m-d H:i:s'))
+        ->select('id','name')->get();
+    }
+
+
+    /**
+     * 通知同步结果
+     * @param [type] $collection_result
+     * @return void
+     */
+    private function notice($collection_result){
+        $role = Roles::where('identify','contentadmin')->select('id','role_name')->first();
+        $notice_obj = [];
+        if($role){
+            $notice_obj[] = ['id'=>$role->id,'name'=>$role->role_name];
+        }
+
+        $admin_role = Roles::where('identify','admin')->select('id','role_name')->first();
+        if($admin_role){
+            $notice_obj[] = ['id'=>$admin_role->id,'name'=>$admin_role->role_name];
+        }
+        if(!$notice_obj){
+            $notice_obj = [['id'=>6,'name'=>'内容管理员']];
+        }
+
+        $end_time = date('Y-m-d H:i:s');
+        $count = $collection_result->count();
+        $books = $collection_result->pluck('name')->implode(',');
+        $content =  $this->start_time.' 同步'.$this->cp_name."任务执行完成\r\n此次执行任务在 {$end_time}执行完成,增量同步{$count}本书如下:\r\n".$books;
+
+        NoticesService::addNotice([
+            'title' => $this->cp_name.'书籍同步完成',
+            'notice_type_id' => 2,
+            'type' => 3,
+            'notice_obj'=>$notice_obj,
+            'is_popup' => 1,
+            'content' => $content
+        ]);
+    }
+}

+ 56 - 0
app/Console/Kernel.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace App\Console;
+
+use Illuminate\Console\Scheduling\Schedule;
+use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
+
+class Kernel extends ConsoleKernel
+{
+    /**
+     * Define the application's command schedule.
+     *
+     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
+     * @return void
+     */
+    protected function schedule(Schedule $schedule)
+    {
+        // $schedule->command('inspire')->hourly();
+        /**
+         * 从掌维同步cp订阅统计数据
+         */
+        $schedule->command('ContentManage:SyncCpSubscribeStatisticDataFromZW')->dailyAt('13:00');
+        /**
+         * cp结算月统计
+         */
+        $schedule->command('ContentManage:CpSubscribeMonthStatisticData', [
+            '--month' => date_sub(date_create(), date_interval_create_from_date_string('1 month'))->format('Y-m')
+        ])->monthlyOn(1, '15:00');
+        /**
+         * 版权到期通知,每周一上午9点执行.
+         */
+        $schedule->command('ContentManage:BookCopyrightAlert')->weekly()->mondays()->at('09:00');
+        /**
+         * 新的cp方书籍进入内容中台, 通知
+         */
+        $schedule->command('ContentManage:NewCpBookComeIn')->dailyAt("08:30");
+        /**
+         * 保存书籍结算模式
+         */
+        $schedule->command('ContentManage:SaveBookSettlementMode')->daily();
+
+        $schedule->command('ContentManage:cpcollection')->everyMinute();
+    }
+
+    /**
+     * Register the commands for the application.
+     *
+     * @return void
+     */
+    protected function commands()
+    {
+        $this->load(__DIR__.'/Commands');
+
+        require base_path('routes/console.php');
+    }
+}

+ 33 - 0
app/Events/Create.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Events;
+
+use Illuminate\Broadcasting\InteractsWithSockets;
+use Illuminate\Broadcasting\PrivateChannel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+class Create
+{
+    use Dispatchable, InteractsWithSockets, SerializesModels;
+
+    /**
+     * Create a new event instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Get the channels the event should broadcast on.
+     *
+     * @return \Illuminate\Broadcasting\Channel|array
+     */
+    public function broadcastOn()
+    {
+        return new PrivateChannel('channel-name');
+    }
+}

+ 33 - 0
app/Events/Test.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Events;
+
+use Illuminate\Broadcasting\InteractsWithSockets;
+use Illuminate\Broadcasting\PrivateChannel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+class Test
+{
+    use Dispatchable, InteractsWithSockets, SerializesModels;
+
+    /**
+     * Create a new event instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Get the channels the event should broadcast on.
+     *
+     * @return \Illuminate\Broadcasting\Channel|array
+     */
+    public function broadcastOn()
+    {
+        return new PrivateChannel('channel-name');
+    }
+}

+ 85 - 0
app/Exceptions/Handler.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Exceptions;
+
+use Catch\Enums\Code;
+use Catch\Exceptions\CatchException;
+use Catch\Exceptions\FailedException;
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+use Illuminate\Http\JsonResponse;
+use Symfony\Component\HttpFoundation\Response;
+use Throwable;
+
+class Handler extends ExceptionHandler
+{
+    /**
+     * A list of exception types with their corresponding custom log levels.
+     *
+     * @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
+     */
+    protected $levels = [
+        //
+    ];
+
+    /**
+     * A list of the exception types that are not reported.
+     *
+     * @var array<int, class-string<\Throwable>>
+     */
+    protected $dontReport = [
+        //
+    ];
+
+    /**
+     * A list of the inputs that are never flashed to the session on validation exceptions.
+     *
+     * @var array<int, string>
+     */
+    protected $dontFlash = [
+        'current_password',
+        'password',
+        'password_confirmation',
+    ];
+
+    /**
+     * Register the exception handling callbacks for the application.
+     *
+     * @return void
+     */
+    public function register()
+    {
+        $this->reportable(function (Throwable $e) {
+            //
+        });
+    }
+
+
+    /**
+     * render
+     *
+     * @param $request
+     * @param Throwable $e
+     * @return JsonResponse|Response
+     * @throws Throwable
+     */
+    public function render($request, Throwable $e): JsonResponse|Response
+    {
+        $message = $e->getMessage();
+
+        if (method_exists($e, 'getStatusCode')) {
+            if ($e->getStatusCode() == Response::HTTP_NOT_FOUND) {
+                $message = '路由未找到或未注册';
+            }
+        }
+
+        $e = new FailedException($message ?: 'Server Error', $e instanceof CatchException ? $e->getCode() : Code::FAILED);
+
+        $response = parent::render($request, $e);
+
+        $response->header('Access-Control-Allow-Origin', '*');
+        $response->header('Access-Control-Allow-Methods', '*');
+        $response->header('Access-Control-Allow-Headers', '*');
+
+        return $response;
+    }
+}

+ 13 - 0
app/Http/Controllers/Controller.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
+use Illuminate\Foundation\Bus\DispatchesJobs;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Routing\Controller as BaseController;
+
+class Controller extends BaseController
+{
+    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
+}

+ 67 - 0
app/Http/Kernel.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Http;
+
+use Illuminate\Foundation\Http\Kernel as HttpKernel;
+
+class Kernel extends HttpKernel
+{
+    /**
+     * The application's global HTTP middleware stack.
+     *
+     * These middleware are run during every request to your application.
+     *
+     * @var array<int, class-string|string>
+     */
+    protected $middleware = [
+        // \App\Http\Middleware\TrustHosts::class,
+        \App\Http\Middleware\TrustProxies::class,
+        \Illuminate\Http\Middleware\HandleCors::class,
+        \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
+        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
+        \App\Http\Middleware\TrimStrings::class,
+        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
+    ];
+
+    /**
+     * The application's route middleware groups.
+     *
+     * @var array<string, array<int, class-string|string>>
+     */
+    protected $middlewareGroups = [
+        'web' => [
+            \App\Http\Middleware\EncryptCookies::class,
+            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
+            \Illuminate\Session\Middleware\StartSession::class,
+            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
+            \App\Http\Middleware\VerifyCsrfToken::class,
+            \Illuminate\Routing\Middleware\SubstituteBindings::class,
+        ],
+
+        'api' => [
+            // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
+            'throttle:api',
+            \Illuminate\Routing\Middleware\SubstituteBindings::class
+        ],
+    ];
+
+    /**
+     * The application's route middleware.
+     *
+     * These middleware may be assigned to groups or used individually.
+     *
+     * @var array<string, class-string|string>
+     */
+    protected $routeMiddleware = [
+        'auth' => \App\Http\Middleware\Authenticate::class,
+        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
+        'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
+        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
+        'can' => \Illuminate\Auth\Middleware\Authorize::class,
+        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
+        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
+        'signed' => \App\Http\Middleware\ValidateSignature::class,
+        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
+        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
+    ];
+}

+ 21 - 0
app/Http/Middleware/Authenticate.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Auth\Middleware\Authenticate as Middleware;
+
+class Authenticate extends Middleware
+{
+    /**
+     * Get the path the user should be redirected to when they are not authenticated.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return string|null
+     */
+    protected function redirectTo($request)
+    {
+        if (! $request->expectsJson()) {
+            return route('login');
+        }
+    }
+}

+ 17 - 0
app/Http/Middleware/EncryptCookies.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
+
+class EncryptCookies extends Middleware
+{
+    /**
+     * The names of the cookies that should not be encrypted.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        //
+    ];
+}

+ 17 - 0
app/Http/Middleware/PreventRequestsDuringMaintenance.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
+
+class PreventRequestsDuringMaintenance extends Middleware
+{
+    /**
+     * The URIs that should be reachable while maintenance mode is enabled.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        //
+    ];
+}

+ 32 - 0
app/Http/Middleware/RedirectIfAuthenticated.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Providers\RouteServiceProvider;
+use Closure;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+
+class RedirectIfAuthenticated
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
+     * @param  string|null  ...$guards
+     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
+     */
+    public function handle(Request $request, Closure $next, ...$guards)
+    {
+        $guards = empty($guards) ? [null] : $guards;
+
+        foreach ($guards as $guard) {
+            if (Auth::guard($guard)->check()) {
+                return redirect(RouteServiceProvider::HOME);
+            }
+        }
+
+        return $next($request);
+    }
+}

+ 19 - 0
app/Http/Middleware/TrimStrings.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
+
+class TrimStrings extends Middleware
+{
+    /**
+     * The names of the attributes that should not be trimmed.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        'current_password',
+        'password',
+        'password_confirmation',
+    ];
+}

+ 20 - 0
app/Http/Middleware/TrustHosts.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Http\Middleware\TrustHosts as Middleware;
+
+class TrustHosts extends Middleware
+{
+    /**
+     * Get the host patterns that should be trusted.
+     *
+     * @return array<int, string|null>
+     */
+    public function hosts()
+    {
+        return [
+            $this->allSubdomainsOfApplicationUrl(),
+        ];
+    }
+}

+ 28 - 0
app/Http/Middleware/TrustProxies.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Http\Middleware\TrustProxies as Middleware;
+use Illuminate\Http\Request;
+
+class TrustProxies extends Middleware
+{
+    /**
+     * The trusted proxies for this application.
+     *
+     * @var array<int, string>|string|null
+     */
+    protected $proxies;
+
+    /**
+     * The headers that should be used to detect proxies.
+     *
+     * @var int
+     */
+    protected $headers =
+        Request::HEADER_X_FORWARDED_FOR |
+        Request::HEADER_X_FORWARDED_HOST |
+        Request::HEADER_X_FORWARDED_PORT |
+        Request::HEADER_X_FORWARDED_PROTO |
+        Request::HEADER_X_FORWARDED_AWS_ELB;
+}

+ 22 - 0
app/Http/Middleware/ValidateSignature.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
+
+class ValidateSignature extends Middleware
+{
+    /**
+     * The names of the query string parameters that should be ignored.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        // 'fbclid',
+        // 'utm_campaign',
+        // 'utm_content',
+        // 'utm_medium',
+        // 'utm_source',
+        // 'utm_term',
+    ];
+}

+ 17 - 0
app/Http/Middleware/VerifyCsrfToken.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
+
+class VerifyCsrfToken extends Middleware
+{
+    /**
+     * The URIs that should be excluded from CSRF verification.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        //
+    ];
+}

+ 345 - 0
app/Libs/Helpers.php

@@ -0,0 +1,345 @@
+<?php
+
+
+use Illuminate\Http\UploadedFile;
+use Modules\Common\Support\Upload\Uploader;
+use PhpOffice\PhpSpreadsheet\IOFactory;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use Modules\Common\Support\Trace\CustomizeLogger;
+use PHPMailer\PHPMailer\PHPMailer;
+
+if(!function_exists("str_decode")){
+    /**
+     * 字符解密
+     * name: str_decode
+     * @param $str
+     * @return int
+     * date 2022/09/27 11:38
+     */
+    function str_decode($str){
+
+        $decode = Hashids::decode($str);
+        $decode = is_array($decode) ? array_shift($decode) : $decode;
+        if(empty($decodeBid)){
+            myLog("StrDecodeError")->info("str : {$str}, decode : ".var_export($decode,true));
+        }
+        return intval($decode);
+    }
+}
+
+if (!function_exists('str_encode')){
+    /***
+     *  字符加密
+     * name: str_decode
+     * @param mixed $str
+     * @return mixed
+     * date 2022/09/27 11:38
+     */
+    function str_encode($str)
+    {
+        return Hashids::encode($str);
+    }
+}
+
+
+
+
+if (!function_exists('is_empty')){
+    /**
+     * 判断数据是否为空
+     * name: is_empty
+     * @param $data
+     * @return bool 空返回true 非空返回false
+     * date 2022/11/18 11:39
+     */
+    function is_empty($data): bool
+    {
+        if (is_object($data)){
+            if (method_exists($data,'isEmpty')){
+                return  $data->isEmpty();
+            }
+
+            return empty(get_object_vars($data));
+        }
+
+        return  empty($data);
+    }
+}
+
+if (!function_exists('column_str')) {
+    /**
+     * 列转化
+     * @param $key
+     * @return string
+     */
+    function column_str($key)
+    {
+        $array = array(
+            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+            'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
+            'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ',
+            'CA', 'CB', 'CC', 'CD', 'CE', 'CF', 'CG', 'CH', 'CI', 'CJ', 'CK', 'CL', 'CM', 'CN', 'CO', 'CP', 'CQ', 'CR', 'CS', 'CT', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ',
+            'DA', 'DB', 'DC', 'DD', 'DE', 'DF', 'DG', 'DH', 'DI', 'DJ', 'DK', 'DL', 'DM', 'DN', 'DO', 'DP', 'DQ', 'DR', 'DS', 'DT', 'DU', 'DV', 'DW', 'DX', 'DY', 'DZ',
+            'EA', 'EB', 'EC', 'ED', 'EE', 'EF', 'EG', 'EH', 'EI', 'EJ', 'EK', 'EL', 'EM', 'EN', 'EO', 'EP', 'EQ', 'ER', 'ES', 'ET', 'EU', 'EV', 'EW', 'EX', 'EY', 'EZ'
+        );
+        return $array[$key];
+    }
+}
+
+if (!function_exists('column')) {
+    /**
+     * Excel 列转化
+     * @param $key
+     * @param mixed $columns
+     * @return string
+     */
+    function column($key, $columns = 1)
+    {
+        return column_str($key) . $columns;
+    }
+}
+
+if (!function_exists('export')) {
+    /***
+     * @param mixed $list 导出的数据
+     * @param mixed $params 标题设置
+     * @throws PHPExcel_Exception
+     * @throws PHPExcel_Reader_Exception
+     */
+    function export($list, $params = array())
+    {
+
+        if (PHP_SAPI == 'cli') {
+            die('This example should only be run from a Web Browser');
+        }
+
+        $excel = new \PHPExcel();
+        $excel->getProperties()->setCreator("植宇")->setLastModifiedBy("植宇")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("report file");
+        $sheet = $excel->setActiveSheetIndex(0);
+        $rowNum = 1;
+        foreach ($params['columns'] as $key => $column) {
+            $sheet->setCellValue(column($key, $rowNum), $column['title']);
+            if (!empty($column['width'])) {
+                $sheet->getColumnDimension(column_str($key))->setWidth($column['width']);
+            }
+        }
+        $rowNum++;
+        $len = count($params['columns']);;
+        foreach ($list as $row) {
+
+            for ($i = 0; $i < $len; $i++) {
+                $value = $row[$params['columns'][$i]['field']] ?? '';
+                $sheet->setCellValue(column($i, $rowNum), $value);
+            }
+            $rowNum++;
+        }
+        $excel->getActiveSheet()->setTitle($params['title']);
+        $filename = urlencode($params['title'] . '-' . date('Y-m-d H:i', time()));
+        ob_end_clean();
+        header('Content-Type: application/octet-stream');
+        header('Content-Disposition: attachment;filename="' . $filename . '.xlsx"');
+        header('Cache-Control: max-age=0');
+        $writer = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
+        $writer->save("php://output");
+    }
+}
+
+/**
+ * 输出到浏览器(需要设置header头)
+ * @param string $fileName 文件名
+ * @param string $fileType 文件类型
+ */
+function excelBrowserExport($fileName, $fileType) {
+
+    //文件名称校验
+    if(!$fileName) {
+        trigger_error('文件名不能为空', E_USER_ERROR);
+    }
+
+    //Excel文件类型校验
+    $type = ['Excel2007', 'Xlsx', 'Excel5', 'xls'];
+    if(!in_array($fileType, $type)) {
+        trigger_error('未知文件类型', E_USER_ERROR);
+    }
+
+    if($fileType == 'Excel2007' || $fileType == 'Xlsx') {
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+        header('Content-Disposition: attachment;filename="'.$fileName.'.xlsx"');
+        header('Cache-Control: max-age=0');
+    } else { //Excel5
+        header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment;filename="'.$fileName.'.xls"');
+        header('Cache-Control: max-age=0');
+    }
+}
+
+/**
+ * 导出excel
+ * @param $header 第一行,表头
+ * <pre>
+ *  ['书名', 'bid', '版权方']
+ * </pre>
+ * @param $datas 表内容,和表头一一对应
+ * <pre>
+ * [
+ *  ['aa', 1, 'bb'],
+ *  ['aa', 1, 'bb'],
+ *  ....
+ *  ['aa', 1, 'bb'],
+ *  ['aa', 1, 'bb'],
+ * ]
+ * </pre>
+ * @param $fileName 导出文件名
+ * @param string $fileType
+ * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
+ */
+function exportExcelXslx($header, $datas, $fileName, $fileType = 'Xlsx') {
+    $spreadsheet = new Spreadsheet();
+    $worksheet = $spreadsheet->getActiveSheet();
+
+//    $worksheet->setTitle('数据中心');
+
+    foreach ($header as $key => $value) {
+        $worksheet->setCellValue([$key+1, 1], $value);
+    }
+
+    $row = 2; //从第二行开始
+    foreach ($datas as $item) {
+        $column = 1;
+
+        foreach ($item as $value) {
+            $worksheet->setCellValue([$column, $row], $value);
+            $column++;
+        }
+        $row++;
+    }
+
+
+
+    $writer = IOFactory::createWriter($spreadsheet, $fileType); //按照指定格式生成Excel文件
+    excelBrowserExport($fileName, $fileType);
+    $writer->save('php://output');
+}
+
+/**
+ * 发送邮件
+ * @param $to_email 收件人
+ * <pre>
+ *  [
+ *  ['address' => 'aa@bb.com', 'name' => 'aa'],
+ *  ......,
+ *  ['address' => 'aa@bb.com', 'name' => 'aa'],
+ * ]
+ * </pre>
+ * @param $param
+ * <pre>
+ *  [
+ *      'subject' => "xxxxxx" , // 标题
+ *      'body' => 'xxxx', // 邮件内容,如果内容需要换行,使用 <br>
+ * ]
+ * </pre>
+ * @param string $accessory
+ */
+function sendEmail($to_email, $param, $accessory = '')
+{
+    $mail = new PHPMailer(true);// Passing `true` enables exceptions
+    $mail->CharSet = 'UTF-8';//'UTF-8';
+    try {
+        $mail->SMTPDebug = 0;                                 // Enable verbose debug output
+        $mail->isSMTP();                                      // Set mailer to use SMTP
+        $mail->Host = 'smtp.exmail.qq.com';     //$mail->Host = 'smtp.126.com'; Specify main and backup SMTP servers
+        $mail->SMTPAuth = true;                               // Enable SMTP authentication
+        $mail->Username = 'sendemail01@zkanshu.com'; //$mail->Username = 'tushengxiang@126.com';                // SMTP username
+        $mail->Password = '5jBekvU2jJ2Ketue';                           // SMTP password
+        $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
+        $mail->Port = 465;                                    // TCP port to connect to
+
+        //Recipients
+        $mail->setFrom('sendemail01@zkanshu.com', 'System');
+        $mail->addAddress($to_email[0]['address'], $to_email[0]['name']);
+        array_shift($to_email);
+        foreach ($to_email as $item) {
+            $mail->addCC($item['address'], $item['name']);     // Add a recipient
+        }
+
+        //Attachments
+        if ($accessory) $mail->addAttachment($accessory);// Add attachments
+
+        $mail->isHTML(true);
+        $mail->Subject = $param['subject'];
+        $mail->Body = $param['body'];
+        $mail->send();
+    } catch (\Exception $e) {
+        \Log::warning('发送邮件失败:' . $mail->ErrorInfo, $e->getTrace());
+    }
+}
+
+/**
+ * 获取日志对象
+ * @param $fileName 保存日志的名称
+ * @param string $logLevel 日志等级
+ * @param int $logDays 日志保留的天数
+ * @return \Psr\Log\LoggerInterface
+ */
+function myLog($fileName, $logLevel='info', $logDays = 7) :\Psr\Log\LoggerInterface{
+    return CustomizeLogger::getLogger($fileName, $logLevel, $logDays);
+}
+
+
+if (!function_exists('get_date')) {
+    /**
+     * 获取时间
+     * @param mixed $time
+     * @param mixed $format
+     * @return false|string
+     */
+    function get_date($time = 0, $format = "Y-m-d H:i:s")
+    {
+        $time = intval($time);
+        if ($time <= 0) {
+            $time = time();
+        }
+        return date($format, $time);
+    }
+}
+
+/**
+ * 华为obs文件上传
+ * @param UploadedFile $file
+ * @return array
+ */
+function huaweiObsUpload(UploadedFile $file) {
+    $uploader = new Uploader();
+    $uploader->setDriver('HuaweiOBS');
+    return  $uploader->upload($file);
+}
+
+
+if (!function_exists("random")) {
+
+    /**
+     * [random 生成随机字符串]
+     * @wzq
+     * @DtuateTime 2020-09-08
+     * @param      [type]     $length  [长度]
+     * @param mixed $numeric [是否仅是数字]
+     * @return string [type]              [string]
+     * @version    v1
+     */
+    function random($length, $numeric = false): string
+    {
+        $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
+        $seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed));
+        if ($numeric) {
+            $hash = '';
+        } else {
+            $hash = chr(rand(1, 26) + rand(0, 1) * 32 + 64);
+            $length--;
+        }
+        $max = strlen($seed) - 1;
+        for ($i = 0; $i < $length; $i++) {
+            $hash .= $seed[mt_rand(0, $max)] ?? "";
+        }
+        return $hash;
+    }
+}

+ 35 - 0
app/Libs/HuaweiObsSdk/Help on License

@@ -0,0 +1,35 @@
+This help guides Huawei engineers to add or modify the license announcement
+during the development.
+
+In the case that you add a new file, the text below should be added in the head.
+    Copyright 2019 Huawei Technologies Co.,Ltd.
+
+    Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+    this file except in compliance with the License.  You may obtain a copy of the
+    License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software distributed
+    under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+    CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations under the License.
+    
+
+In the case that you modify one existing file, the text below should be added after
+the exiting license.
+      Huawei has modified this source file.
+
+            Copyright 2019 Huawei Technologies Co., Ltd.                                        
+
+            Licensed under the Apache License, Version 2.0 (the "License"); you may not      
+            use this file except in compliance with the License. You may obtain a copy of    
+            the License at                                                                   
+
+                 http://www.apache.org/licenses/LICENSE-2.0                                   
+
+            Unless required by applicable law or agreed to in writing, software              
+            distributed under the License is distributed on an "AS IS" BASIS, WITHOUT        
+            WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the         
+            License for the specific language governing permissions and limitations under    
+            the License.    

+ 219 - 0
app/Libs/HuaweiObsSdk/LICENSE

@@ -0,0 +1,219 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright 2019 Huawei Technologies Co., Ltd.  
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+   OPEN SOURCE SOFTWARE NOTICE
+
+   This document contains open source software notice for this product. And this document is confidential information of copyright holder. Recipient shall protect it in due care and shall not disseminate it without permission.
+
+   Warranty Disclaimer
+
+   THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. 
+
+   Copyright Notice and License Texts
+
+   Written Offer
+
+   This product contains software whose rights holders license it on the terms of the GNU General Public License, version 2 (GPLv2) or other open source software license. We will provide you with the source code of the software licensed under related license if you send us a written request by mail or email to the following addresses:
+   foss@huawei.com
+   detailing the name of the product and the firmware version for which you need the source code and indicating how we can contact you.
+
+   PLEASE NOTE THAT WE WILL ASK YOU TO PAY US FOR THE COSTS OF A DATA CARRIER AND THE POSTAL CHARGES TO SEND THE DATA CARRIER TO YOU. THIS OFFER IS VALID FOR THREE YEARS FROM THE MOMENT WE DISTRIBUTED THE PRODUCT AND VALID FOR AS LONG AS WE OFFER SPARE PARTS OR CUSTOMER SUPPORT FOR THAT PRODUCT MODEL.

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 39 - 0
app/Libs/HuaweiObsSdk/Notice.MD


+ 63 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Common/CheckoutStream.php

@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Common;
+
+use Psr\Http\Message\StreamInterface;
+use GuzzleHttp\Psr7\StreamDecoratorTrait;
+use Obs\ObsException;
+
+class CheckoutStream implements StreamInterface {
+    use StreamDecoratorTrait;
+    
+    private $expectedLength;
+    private $readedCount = 0;
+
+    public function __construct(StreamInterface $stream, $expectedLength) {
+        $this->stream = $stream;
+        $this->expectedLength = $expectedLength;
+    }
+
+    public function getContents() {
+        $contents = $this->stream->getContents();
+        $length = strlen($contents);
+        if ($this->expectedLength !== null && floatval($length) !== $this->expectedLength) {
+            $this -> throwObsException($this->expectedLength, $length);
+        }
+        return $contents;
+    }
+
+    public function read($length) {
+        $string = $this->stream->read($length);
+        if ($this->expectedLength !== null) {
+            $this->readedCount += strlen($string);
+            if ($this->stream->eof()) {
+                if (floatval($this->readedCount) !== $this->expectedLength) {
+                    $this -> throwObsException($this->expectedLength, $this->readedCount);
+                }
+            }
+        }    
+        return $string;
+    }
+
+    public function throwObsException($expectedLength, $reaLength) {
+        $obsException = new ObsException('premature end of Content-Length delimiter message body (expected:' . $expectedLength . '; received:' . $reaLength . ')');
+        $obsException->setExceptionType('server');
+        throw $obsException;
+    }
+}
+

+ 23 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Common/ITransform.php

@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Common;
+
+interface ITransform {
+    public function transform($sign, $para);
+}
+

+ 257 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Common/Model.php

@@ -0,0 +1,257 @@
+<?php
+
+/**
+ * Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
+
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Obs\Internal\Common;
+
+class Model implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInterface
+{
+	protected $data;
+	
+	public function __construct(array $data = [])
+	{
+		$this->data = $data;
+	}
+	
+	public function count()
+	{
+		return count($this->data);
+	}
+	
+	public function getIterator()
+	{
+		return new \ArrayIterator($this->data);
+	}
+	
+	public function toArray()
+	{
+		return $this->data;
+	}
+	
+	public function clear()
+	{
+		$this->data = [];
+		
+		return $this;
+	}
+	
+	public function getAll(array $keys = null)
+	{
+		return $keys ? array_intersect_key($this->data, array_flip($keys)) : $this->data;
+	}
+	
+	public function get($key)
+	{
+		return isset($this->data[$key]) ? $this->data[$key] : null;
+	}
+	
+	public function set($key, $value)
+	{
+		$this->data[$key] = $value;
+		
+		return $this;
+	}
+	
+	public function add($key, $value)
+	{
+		if (!array_key_exists($key, $this->data)) {
+			$this->data[$key] = $value;
+		} elseif (is_array($this->data[$key])) {
+			$this->data[$key][] = $value;
+		} else {
+			$this->data[$key] = [$this->data[$key], $value];
+		}
+		
+		return $this;
+	}
+	
+	public function remove($key)
+	{
+		unset($this->data[$key]);
+		
+		return $this;
+	}
+	
+	public function getKeys()
+	{
+		return array_keys($this->data);
+	}
+	
+	public function hasKey($key)
+	{
+		return array_key_exists($key, $this->data);
+	}
+	
+	public function keySearch($key)
+	{
+		foreach (array_keys($this->data) as $k) {
+			if (!strcasecmp($k, $key)) {
+				return $k;
+			}
+		}
+		
+		return false;
+	}
+	
+	
+	public function hasValue($value)
+	{
+		return array_search($value, $this->data);
+	}
+	
+	public function replace(array $data)
+	{
+		$this->data = $data;
+		
+		return $this;
+	}
+	
+	public function merge($data)
+	{
+		foreach ($data as $key => $value) {
+			$this->add($key, $value);
+		}
+		
+		return $this;
+	}
+	
+	public function overwriteWith($data)
+	{
+		if (is_array($data)) {
+			$this->data = $data + $this->data;
+		} else {
+			foreach ($data as $key => $value) {
+				$this->data[$key] = $value;
+			}
+		}
+		
+		return $this;
+	}
+	
+	public function map(\Closure $closure, array $context = [], $static = true)
+	{
+		$collection = $static ? new static() : new self();
+		foreach ($this as $key => $value) {
+			$collection->add($key, $closure($key, $value, $context));
+		}
+		
+		return $collection;
+	}
+	
+	public function filter(\Closure $closure, $static = true)
+	{
+		$collection = ($static) ? new static() : new self();
+		foreach ($this->data as $key => $value) {
+			if ($closure($key, $value)) {
+				$collection->add($key, $value);
+			}
+		}
+		
+		return $collection;
+	}
+	
+	public function offsetExists($offset)
+	{
+		return isset($this->data[$offset]);
+	}
+	
+	public function offsetGet($offset)
+	{
+		return isset($this->data[$offset]) ? $this->data[$offset] : null;
+	}
+	
+	public function offsetSet($offset, $value)
+	{
+		$this->data[$offset] = $value;
+	}
+	
+	public function offsetUnset($offset)
+	{
+		unset($this->data[$offset]);
+	}
+	
+	public function setPath($path, $value)
+	{
+		$current =& $this->data;
+		$queue = explode('/', $path);
+		while (null !== ($key = array_shift($queue))) {
+			if (!is_array($current)) {
+				throw new \RuntimeException("Trying to setPath {$path}, but {$key} is set and is not an array");
+			} elseif (!$queue) {
+				$current[$key] = $value;
+			} elseif (isset($current[$key])) {
+				$current =& $current[$key];
+			} else {
+				$current[$key] = [];
+				$current =& $current[$key];
+			}
+		}
+		
+		return $this;
+	}
+	
+	public function getPath($path, $separator = '/', $data = null)
+	{
+		if ($data === null) {
+			$data =& $this->data;
+		}
+		
+		$path = is_array($path) ? $path : explode($separator, $path);
+		while (null !== ($part = array_shift($path))) {
+			if (!is_array($data)) {
+				return null;
+			} elseif (isset($data[$part])) {
+				$data =& $data[$part];
+			} elseif ($part != '*') {
+				return null;
+			} else {
+				// Perform a wildcard search by diverging and merging paths
+				$result = [];
+				foreach ($data as $value) {
+					if (!$path) {
+						$result = array_merge_recursive($result, (array) $value);
+					} elseif (null !== ($test = $this->getPath($path, $separator, $value))) {
+						$result = array_merge_recursive($result, (array) $test);
+					}
+				}
+				return $result;
+			}
+		}
+		
+		return $data;
+	}
+	
+	public function __toString()
+	{
+		$output = 'Debug output of ';
+		$output .= 'model';
+		$output = str_repeat('=', strlen($output)) . "\n" . $output . "\n" . str_repeat('=', strlen($output)) . "\n\n";
+		$output .= "Model data\n-----------\n\n";
+		$output .= "This data can be retrieved from the model object using the get() method of the model "
+				. "(e.g. \$model->get(\$key)) or accessing the model like an associative array (e.g. \$model['key']).\n\n";
+		$lines = array_slice(explode("\n", trim(print_r($this->toArray(), true))), 2, -1);
+		$output .=  implode("\n", $lines);
+		
+		return $output . "\n";
+	}
+}

+ 78 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Common/ObsTransform.php

@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Common;
+
+use Obs\ObsClient;
+
+class ObsTransform implements ITransform {
+    private static $instance;
+    
+    private function __construct(){}
+    
+    public static function getInstance() {
+        if (!(self::$instance instanceof ObsTransform)) {
+            self::$instance = new ObsTransform();
+        }
+        return self::$instance;
+    }
+     
+    
+    public function transform($sign, $para) {
+        if ($sign === 'aclHeader') {
+            $para = $this->transAclHeader($para);
+        } else if ($sign === 'aclUri') {
+            $para = $this->transAclGroupUri($para);
+        } else if ($sign == 'event') {
+            $para = $this->transNotificationEvent($para);
+        } else if ($sign == 'storageClass') {
+            $para = $this->transStorageClass($para);
+        }
+        return $para;
+    }
+    
+    private function transAclHeader($para) {
+        if ($para === ObsClient::AclAuthenticatedRead || $para === ObsClient::AclBucketOwnerRead || 
+                $para === ObsClient::AclBucketOwnerFullControl || $para === ObsClient::AclLogDeliveryWrite) {
+            $para = null;
+        }
+        return $para;
+    }
+    
+    private function transAclGroupUri($para) {
+        if ($para === ObsClient::GroupAllUsers) {
+            $para = ObsClient::AllUsers;
+        }
+        return $para;
+    }
+    
+    private function transNotificationEvent($para) {
+        $pos = strpos($para, 's3:');
+        if ($pos !== false && $pos === 0) {
+            $para = substr($para, 3);
+        }
+        return $para;
+    }
+    
+    private function transStorageClass($para) {
+        $search = array('STANDARD', 'STANDARD_IA', 'GLACIER');
+        $repalce = array(ObsClient::StorageClassStandard, ObsClient::StorageClassWarm, ObsClient::StorageClassCold);
+        $para = str_replace($search, $repalce, $para);
+        return $para;
+    }
+}
+

+ 116 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Common/SchemaFormatter.php

@@ -0,0 +1,116 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Common;
+
+
+class SchemaFormatter
+{
+    protected static $utcTimeZone;
+
+    public static function format($fmt, $value)
+    {   
+        if($fmt === 'date-time'){
+            return self::formatDateTime($value);
+        }
+        
+        if($fmt === 'data-time-http'){
+            return self::formatDateTimeHttp($value);
+        }
+        
+        if($fmt === 'data-time-middle'){
+            return self::formatDateTimeMiddle($value);
+        }
+        
+        if($fmt === 'date'){
+            return self::formatDate($value);
+        }
+        
+        if($fmt === 'timestamp'){
+            return self::formatTimestamp($value);
+        }
+        
+        if($fmt === 'boolean-string'){
+            return self::formatBooleanAsString($value);
+        }
+        
+        return $value;
+    }
+    
+    public static function formatDateTimeMiddle($dateTime)
+    {
+    	if (is_string($dateTime)) {
+    		$dateTime = new \DateTime($dateTime);
+    	}
+    	
+    	if ($dateTime instanceof \DateTime) {
+    		return $dateTime -> format('Y-m-d\T00:00:00\Z');
+    	}
+    	return null;
+    }
+
+    public static function formatDateTime($value)
+    {
+        return self::dateFormatter($value, 'Y-m-d\TH:i:s\Z');
+    }
+
+    public static function formatDateTimeHttp($value)
+    {
+        return self::dateFormatter($value, 'D, d M Y H:i:s \G\M\T');
+    }
+
+    public static function formatDate($value)
+    {
+        return self::dateFormatter($value, 'Y-m-d');
+    }
+
+    public static function formatTime($value)
+    {
+        return self::dateFormatter($value, 'H:i:s');
+    }
+
+    public static function formatBooleanAsString($value)
+    {
+        return filter_var($value, FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false';
+    }
+
+    public static function formatTimestamp($value)
+    {
+        return (int) self::dateFormatter($value, 'U');
+    }
+
+    private static function dateFormatter($dt, $fmt)
+    {
+        if (is_numeric($dt)) {
+            return gmdate($fmt, (int) $dt);
+        }
+
+        if (is_string($dt)) {
+            $dt = new \DateTime($dt);
+        }
+
+        if ($dt instanceof \DateTime) {
+            if (!self::$utcTimeZone) {
+                self::$utcTimeZone = new \DateTimeZone('UTC');
+            }
+            
+            return $dt->setTimezone(self::$utcTimeZone)->format($fmt);
+        }
+
+        return null;
+    }
+}

+ 430 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Common/SdkCurlFactory.php

@@ -0,0 +1,430 @@
+<?php
+
+/**
+ * Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
+
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Obs\Internal\Common;
+
+use GuzzleHttp\Psr7;
+use GuzzleHttp\Psr7\LazyOpenStream;
+use Psr\Http\Message\RequestInterface;
+use GuzzleHttp\Handler\CurlFactoryInterface;
+use GuzzleHttp\Handler\EasyHandle;
+
+class SdkCurlFactory implements CurlFactoryInterface
+{
+    private $handles = [];
+
+    private $maxHandles;
+
+    public function __construct($maxHandles)
+    {
+        $this->maxHandles = $maxHandles;
+    }
+
+    public function create(RequestInterface $request, array $options): EasyHandle
+    {
+        if (isset($options['curl']['body_as_string'])) {
+            $options['_body_as_string'] = $options['curl']['body_as_string'];
+            unset($options['curl']['body_as_string']);
+        }
+        
+        $easy = new EasyHandle;
+        $easy->request = $request;
+        $easy->options = $options;
+        $conf = $this->getDefaultConf($easy);
+        $this->applyMethod($easy, $conf);
+        $this->applyHandlerOptions($easy, $conf);
+        $this->applyHeaders($easy, $conf);
+        
+        
+        unset($conf['_headers']);
+
+        if (isset($options['curl'])) {
+            $conf = array_replace($conf, $options['curl']);
+        }
+
+        $conf[CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
+        if($this->handles){
+           $easy->handle = array_pop($this->handles);
+        }else{
+           $easy->handle = curl_init();
+        }
+        curl_setopt_array($easy->handle, $conf);
+
+        return $easy;
+    }
+    
+    public function close()
+    {
+    	if($this->handles){
+    		foreach ($this->handles as $handle){
+    			curl_close($handle);
+    		}
+ 			unset($this->handles);
+ 			$this->handles = [];
+    	}
+    }
+
+    public function release(EasyHandle $easy): void
+    {
+        $resource = $easy->handle;
+        unset($easy->handle);
+
+        if (count($this->handles) >= $this->maxHandles) {
+            curl_close($resource);
+        } else {
+            curl_setopt($resource, CURLOPT_HEADERFUNCTION, null);
+            curl_setopt($resource, CURLOPT_READFUNCTION, null);
+            curl_setopt($resource, CURLOPT_WRITEFUNCTION, null);
+            curl_setopt($resource, CURLOPT_PROGRESSFUNCTION, null);
+            curl_reset($resource);
+            $this->handles[] = $resource;
+        }
+    }
+
+    private function getDefaultConf(EasyHandle $easy)
+    {
+        $conf = [
+            '_headers'             => $easy->request->getHeaders(),
+            CURLOPT_CUSTOMREQUEST  => $easy->request->getMethod(),
+            CURLOPT_URL            => (string) $easy->request->getUri()->withFragment(''),
+            CURLOPT_RETURNTRANSFER => false,
+            CURLOPT_HEADER         => false,
+            CURLOPT_CONNECTTIMEOUT => 150,
+        ];
+
+        if (defined('CURLOPT_PROTOCOLS')) {
+            $conf[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS;
+        }
+
+        $version = $easy->request->getProtocolVersion();
+        if ($version == 1.1) {
+            $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
+        } elseif ($version == 2.0) {
+            $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
+        } else {
+            $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
+        }
+
+        return $conf;
+    }
+
+    private function applyMethod(EasyHandle $easy, array &$conf)
+    {
+        $body = $easy->request->getBody();
+        $size = $body->getSize();
+        
+        if ($size === null || $size > 0) {
+            $this->applyBody($easy->request, $easy->options, $conf);
+            return;
+        }
+
+        $method = $easy->request->getMethod();
+        if ($method === 'PUT' || $method === 'POST') {
+            if (!$easy->request->hasHeader('Content-Length')) {
+                $conf[CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
+            }
+        } elseif ($method === 'HEAD') {
+            $conf[CURLOPT_NOBODY] = true;
+            unset(
+                $conf[CURLOPT_WRITEFUNCTION],
+                $conf[CURLOPT_READFUNCTION],
+                $conf[CURLOPT_FILE],
+                $conf[CURLOPT_INFILE]
+            );
+        }
+    }
+
+    private function applyBody(RequestInterface $request, array $options, array &$conf)
+    {
+        $size = $request->hasHeader('Content-Length')
+            ? (int) $request->getHeaderLine('Content-Length')
+            : $request->getBody()->getSize();
+		            
+        if($request->getBody()->getSize() === $size && $request -> getBody() ->tell() <= 0){
+	        if (($size !== null && $size < 1000000) ||
+	            !empty($options['_body_as_string'])
+	        ) {
+	            $conf[CURLOPT_POSTFIELDS] = (string) $request->getBody();
+	            $this->removeHeader('Content-Length', $conf);
+	            $this->removeHeader('Transfer-Encoding', $conf);
+	        } else {
+	            $conf[CURLOPT_UPLOAD] = true;
+	            if ($size !== null) {
+	                $conf[CURLOPT_INFILESIZE] = $size;
+	                $this->removeHeader('Content-Length', $conf);
+	            }
+	            $body = $request->getBody();
+	            if ($body->isSeekable()) {
+	                $body->rewind();
+	            }
+	            $conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) {
+	                return $body->read($length);
+	            };
+	        }
+        }else{
+        	$body = $request->getBody();
+        	$conf[CURLOPT_UPLOAD] = true;
+        	$conf[CURLOPT_INFILESIZE] = $size;
+        	$readCount = 0;
+        	$conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body, $readCount, $size) {
+        		if($readCount >= $size){
+        			$body -> close();
+        			return '';
+        		}
+        		$readCountOnce = $length <= $size ? $length : $size;
+        		$readCount += $readCountOnce;
+        		return $body->read($readCountOnce);
+        	};
+        }
+            
+            
+
+        if (!$request->hasHeader('Expect')) {
+            $conf[CURLOPT_HTTPHEADER][] = 'Expect:';
+        }
+
+        if (!$request->hasHeader('Content-Type')) {
+            $conf[CURLOPT_HTTPHEADER][] = 'Content-Type:';
+        }
+    }
+
+    private function applyHeaders(EasyHandle $easy, array &$conf)
+    {
+        foreach ($conf['_headers'] as $name => $values) {
+            foreach ($values as $value) {
+                $conf[CURLOPT_HTTPHEADER][] = "$name: $value";
+            }
+        }
+
+        // Remove the Accept header if one was not set
+        if (!$easy->request->hasHeader('Accept')) {
+            $conf[CURLOPT_HTTPHEADER][] = 'Accept:';
+        }
+    }
+
+    private function removeHeader($name, array &$options)
+    {
+        foreach (array_keys($options['_headers']) as $key) {
+            if (!strcasecmp($key, $name)) {
+                unset($options['_headers'][$key]);
+                return;
+            }
+        }
+    }
+
+    private function applyHandlerOptions(EasyHandle $easy, array &$conf)
+    {
+        $options = $easy->options;
+        if (isset($options['verify'])) {
+        	$conf[CURLOPT_SSL_VERIFYHOST] = 0;
+            if ($options['verify'] === false) {
+                unset($conf[CURLOPT_CAINFO]);
+                $conf[CURLOPT_SSL_VERIFYPEER] = false;
+            } else {
+                $conf[CURLOPT_SSL_VERIFYPEER] = true;
+                if (is_string($options['verify'])) {
+                    if (!file_exists($options['verify'])) {
+                        throw new \InvalidArgumentException(
+                            "SSL CA bundle not found: {$options['verify']}"
+                        );
+                    }
+                    if (is_dir($options['verify']) ||
+                        (is_link($options['verify']) && is_dir(readlink($options['verify'])))) {
+                        $conf[CURLOPT_CAPATH] = $options['verify'];
+                    } else {
+                        $conf[CURLOPT_CAINFO] = $options['verify'];
+                    }
+                }
+            }
+        }
+
+        if (!empty($options['decode_content'])) {
+            $accept = $easy->request->getHeaderLine('Accept-Encoding');
+            if ($accept) {
+                $conf[CURLOPT_ENCODING] = $accept;
+            } else {
+                $conf[CURLOPT_ENCODING] = '';
+                $conf[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
+            }
+        }
+
+        if (isset($options['sink'])) {
+            $sink = $options['sink'];
+            if (!is_string($sink)) {
+                try {
+                    $sink = Psr7\stream_for($sink);
+                } catch (\Throwable $e) {
+                    $sink = Psr7\Utils::streamFor($sink);
+                }
+            } elseif (!is_dir(dirname($sink))) {
+                throw new \RuntimeException(sprintf(
+                    'Directory %s does not exist for sink value of %s',
+                    dirname($sink),
+                    $sink
+                ));
+            } else {
+                $sink = new LazyOpenStream($sink, 'w+');
+            }
+            $easy->sink = $sink;
+            $conf[CURLOPT_WRITEFUNCTION] = function ($ch, $write) use ($sink) {
+                return $sink->write($write);
+            };
+        } else {
+            $conf[CURLOPT_FILE] = fopen('php://temp', 'w+');
+            try {
+                $easy->sink = Psr7\stream_for($conf[CURLOPT_FILE]);
+            } catch (\Throwable $e) {
+                $easy->sink = Psr7\Utils::streamFor($conf[CURLOPT_FILE]);
+            }
+        }
+        $timeoutRequiresNoSignal = false;
+        if (isset($options['timeout'])) {
+            $timeoutRequiresNoSignal |= $options['timeout'] < 1;
+            $conf[CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000;
+        }
+
+        if (isset($options['force_ip_resolve'])) {
+            if ('v4' === $options['force_ip_resolve']) {
+                $conf[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
+            } else if ('v6' === $options['force_ip_resolve']) {
+                $conf[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V6;
+            }
+        }
+
+        if (isset($options['connect_timeout'])) {
+            $timeoutRequiresNoSignal |= $options['connect_timeout'] < 1;
+            $conf[CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
+        }
+
+        if ($timeoutRequiresNoSignal && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
+            $conf[CURLOPT_NOSIGNAL] = true;
+        }
+
+        if (isset($options['proxy'])) {
+            if (!is_array($options['proxy'])) {
+                $conf[CURLOPT_PROXY] = $options['proxy'];
+            } else {
+                $scheme = $easy->request->getUri()->getScheme();
+                if (isset($options['proxy'][$scheme])) {
+                    $host = $easy->request->getUri()->getHost();
+                    if (!isset($options['proxy']['no']) ||
+                        !\GuzzleHttp\is_host_in_noproxy($host, $options['proxy']['no'])
+                    ) {
+                        $conf[CURLOPT_PROXY] = $options['proxy'][$scheme];
+                    }
+                }
+            }
+        }
+
+        if (isset($options['cert'])) {
+            $cert = $options['cert'];
+            if (is_array($cert)) {
+                $conf[CURLOPT_SSLCERTPASSWD] = $cert[1];
+                $cert = $cert[0];
+            }
+            if (!file_exists($cert)) {
+                throw new \InvalidArgumentException(
+                    "SSL certificate not found: {$cert}"
+                );
+            }
+            $conf[CURLOPT_SSLCERT] = $cert;
+        }
+
+        if (isset($options['ssl_key'])) {
+            $sslKey = $options['ssl_key'];
+            if (is_array($sslKey)) {
+                $conf[CURLOPT_SSLKEYPASSWD] = $sslKey[1];
+                $sslKey = $sslKey[0];
+            }
+            if (!file_exists($sslKey)) {
+                throw new \InvalidArgumentException(
+                    "SSL private key not found: {$sslKey}"
+                );
+            }
+            $conf[CURLOPT_SSLKEY] = $sslKey;
+        }
+
+        if (isset($options['progress'])) {
+            $progress = $options['progress'];
+            if (!is_callable($progress)) {
+                throw new \InvalidArgumentException(
+                    'progress client option must be callable'
+                );
+            }
+            $conf[CURLOPT_NOPROGRESS] = false;
+            $conf[CURLOPT_PROGRESSFUNCTION] = function () use ($progress) {
+                $args = func_get_args();
+                if (is_resource($args[0])) {
+                    array_shift($args);
+                }
+                call_user_func_array($progress, $args);
+            };
+        }
+
+        if (!empty($options['debug'])) {
+            $conf[CURLOPT_STDERR] = \GuzzleHttp\debug_resource($options['debug']);
+            $conf[CURLOPT_VERBOSE] = true;
+        }
+    }
+
+
+    private function createHeaderFn(EasyHandle $easy)
+    {
+        if (isset($easy->options['on_headers'])) {
+            $onHeaders = $easy->options['on_headers'];
+
+            if (!is_callable($onHeaders)) {
+                throw new \InvalidArgumentException('on_headers must be callable');
+            }
+        } else {
+            $onHeaders = null;
+        }
+
+        return function ($ch, $h) use (
+            $onHeaders,
+            $easy,
+            &$startingResponse
+        ) {
+            $value = trim($h);
+            if ($value === '') {
+                $startingResponse = true;
+                $easy->createResponse();
+                if ($onHeaders !== null) {
+                    try {
+                        $onHeaders($easy->response);
+                    } catch (\Exception $e) {
+                        $easy->onHeadersException = $e;
+                        return -1;
+                    }
+                }
+            } elseif ($startingResponse) {
+                $startingResponse = false;
+                $easy->headers = [$value];
+            } else {
+                $easy->headers[] = $value;
+            }
+            return strlen($h);
+        };
+    }
+}

+ 519 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Common/SdkStreamHandler.php

@@ -0,0 +1,519 @@
+<?php
+
+/**
+ * Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
+
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+namespace Obs\Internal\Common;
+
+use GuzzleHttp\Exception\RequestException;
+use GuzzleHttp\Exception\ConnectException;
+use GuzzleHttp\Promise\FulfilledPromise;
+use GuzzleHttp\Promise\PromiseInterface;
+use GuzzleHttp\Psr7;
+use GuzzleHttp\TransferStats;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\StreamInterface;
+
+class SdkStreamHandler
+{
+    private $lastHeaders = [];
+
+    public function __invoke(RequestInterface $request, array $options)
+    {
+        if (isset($options['delay'])) {
+            usleep($options['delay'] * 1000);
+        }
+
+        $startTime = isset($options['on_stats']) ? microtime(true) : null;
+
+        try {
+            $request = $request->withoutHeader('Expect');
+
+            if (0 === $request->getBody()->getSize()) {
+                $request = $request->withHeader('Content-Length', 0);
+            }
+
+            return $this->createResponse(
+                $request,
+                $options,
+                $this->createStream($request, $options),
+                $startTime
+            );
+        } catch (\InvalidArgumentException $e) {
+            throw $e;
+        } catch (\Exception $e) {
+            $message = $e->getMessage();
+            if (strpos($message, 'getaddrinfo')
+                || strpos($message, 'Connection refused')
+                || strpos($message, "couldn't connect to host")
+            ) {
+                $e = new ConnectException($e->getMessage(), $request, $e);
+            }
+            $e = RequestException::wrapException($request, $e);
+            $this->invokeStats($options, $request, $startTime, null, $e);
+
+            return \GuzzleHttp\Promise\rejection_for($e);
+        }
+    }
+
+    private function invokeStats(
+        array $options,
+        RequestInterface $request,
+        $startTime,
+        ResponseInterface $response = null,
+        $error = null
+    ) {
+        if (isset($options['on_stats'])) {
+            $stats = new TransferStats(
+                $request,
+                $response,
+                microtime(true) - $startTime,
+                $error,
+                []
+            );
+            call_user_func($options['on_stats'], $stats);
+        }
+    }
+
+    private function createResponse(
+        RequestInterface $request,
+        array $options,
+        $stream,
+        $startTime
+    ) {
+        $hdrs = $this->lastHeaders;
+        $this->lastHeaders = [];
+        $parts = explode(' ', array_shift($hdrs), 3);
+        $ver = explode('/', $parts[0])[1];
+        $status = $parts[1];
+        $reason = isset($parts[2]) ? $parts[2] : null;
+        $headers = \GuzzleHttp\headers_from_lines($hdrs);
+        list ($stream, $headers) = $this->checkDecode($options, $headers, $stream);
+        try {
+            $stream = Psr7\stream_for($stream);
+        } catch (\Throwable $e) {
+            $stream = Psr7\Utils::streamFor($stream);
+        }
+        $sink = $stream;
+
+        if (strcasecmp('HEAD', $request->getMethod())) {
+            $sink = $this->createSink($stream, $options);
+        }
+
+        $response = new Psr7\Response($status, $headers, $sink, $ver, $reason);
+
+        if (isset($options['on_headers'])) {
+            try {
+                $options['on_headers']($response);
+            } catch (\Exception $e) {
+                $msg = 'An error was encountered during the on_headers event';
+                $ex = new RequestException($msg, $request, $response, $e);
+                return \GuzzleHttp\Promise\rejection_for($ex);
+            }
+        }
+
+        if ($sink !== $stream) {
+            $this->drain(
+                $stream,
+                $sink,
+                $response->getHeaderLine('Content-Length')
+            );
+        }
+
+        $this->invokeStats($options, $request, $startTime, $response, null);
+
+        return new FulfilledPromise($response);
+    }
+
+    private function createSink(StreamInterface $stream, array $options)
+    {
+        if (!empty($options['stream'])) {
+            return $stream;
+        }
+
+        $sink = isset($options['sink'])
+            ? $options['sink']
+            : fopen('php://temp', 'r+');
+
+        if (is_string($sink)) {
+            return new Psr7\LazyOpenStream($sink, 'w+');
+        }
+
+        try {
+            return Psr7\stream_for($sink);
+        } catch (\Throwable $e) {
+            return Psr7\Utils::streamFor($sink);
+        }
+    }
+
+    private function checkDecode(array $options, array $headers, $stream)
+    {
+        if (!empty($options['decode_content'])) {
+            $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
+            if (isset($normalizedKeys['content-encoding'])) {
+                $encoding = $headers[$normalizedKeys['content-encoding']];
+                if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') {
+                    try {
+                        $stream = new Psr7\InflateStream(
+                            Psr7\stream_for($stream)
+                        );
+                    } catch (\Throwable $th) {
+                        $stream = new Psr7\InflateStream(
+                            Psr7\Utils::streamFor($stream)
+                        );
+                    }
+
+                    $headers['x-encoded-content-encoding']
+                        = $headers[$normalizedKeys['content-encoding']];
+                    unset($headers[$normalizedKeys['content-encoding']]);
+                    if (isset($normalizedKeys['content-length'])) {
+                        $headers['x-encoded-content-length']
+                            = $headers[$normalizedKeys['content-length']];
+
+                        $length = (int) $stream->getSize();
+                        if ($length === 0) {
+                            unset($headers[$normalizedKeys['content-length']]);
+                        } else {
+                            $headers[$normalizedKeys['content-length']] = [$length];
+                        }
+                    }
+                }
+            }
+        }
+
+        return [$stream, $headers];
+    }
+
+    private function drain(
+        StreamInterface $source,
+        StreamInterface $sink,
+        $contentLength
+    ) {
+        Psr7\copy_to_stream(
+            $source,
+            $sink,
+            (strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1
+        );
+
+        $sink->seek(0);
+        $source->close();
+
+        return $sink;
+    }
+
+    private function createResource(callable $callback)
+    {
+        $errors = null;
+        set_error_handler(function ($_, $msg, $file, $line) use (&$errors) {
+            $errors[] = [
+                'message' => $msg,
+                'file'    => $file,
+                'line'    => $line
+            ];
+            return true;
+        });
+
+        $resource = $callback();
+        restore_error_handler();
+
+        if (!$resource) {
+            $message = 'Error creating resource: ';
+            foreach ($errors as $err) {
+                foreach ($err as $key => $value) {
+                    $message .= "[$key] $value" . PHP_EOL;
+                }
+            }
+            throw new \RuntimeException(trim($message));
+        }
+
+        return $resource;
+    }
+
+    private function createStream(RequestInterface $request, array $options)
+    {
+        static $methods;
+        if (!$methods) {
+            $methods = array_flip(get_class_methods(__CLASS__));
+        }
+
+        if ($request->getProtocolVersion() == '1.1'
+            && !$request->hasHeader('Connection')
+        ) {
+            $request = $request->withHeader('Connection', 'close');
+        }
+
+        if (!isset($options['verify'])) {
+            $options['verify'] = true;
+        }
+
+        $params = [];
+        $context = $this->getDefaultContext($request, $options);
+
+        if (isset($options['on_headers']) && !is_callable($options['on_headers'])) {
+            throw new \InvalidArgumentException('on_headers must be callable');
+        }
+
+        if (!empty($options)) {
+            foreach ($options as $key => $value) {
+                $method = "add_{$key}";
+                if (isset($methods[$method])) {
+                    $this->{$method}($request, $context, $value, $params);
+                }
+            }
+        }
+
+        if (isset($options['stream_context'])) {
+            if (!is_array($options['stream_context'])) {
+                throw new \InvalidArgumentException('stream_context must be an array');
+            }
+            $context = array_replace_recursive(
+                $context,
+                $options['stream_context']
+            );
+        }
+
+        if (isset($options['auth'])
+            && is_array($options['auth'])
+            && isset($options['auth'][2])
+            && 'ntlm' == $options['auth'][2]
+        ) {
+
+            throw new \InvalidArgumentException('Microsoft NTLM authentication only supported with curl handler');
+        }
+
+        $uri = $this->resolveHost($request, $options);
+
+        $context = $this->createResource(
+            function () use ($context, $params) {
+                return stream_context_create($context, $params);
+            }
+        );
+
+        return $this->createResource(
+            function () use ($uri, &$http_response_header, $context, $options) {
+                $resource = fopen((string) $uri, 'r', null, $context);
+                $this->lastHeaders = $http_response_header;
+
+                if (isset($options['read_timeout'])) {
+                    $readTimeout = $options['read_timeout'];
+                    $sec = (int) $readTimeout;
+                    $usec = ($readTimeout - $sec) * 100000;
+                    stream_set_timeout($resource, $sec, $usec);
+                }
+
+                return $resource;
+            }
+        );
+    }
+
+    private function resolveHost(RequestInterface $request, array $options)
+    {
+        $uri = $request->getUri();
+
+        if (isset($options['force_ip_resolve']) && !filter_var($uri->getHost(), FILTER_VALIDATE_IP)) {
+            if ('v4' === $options['force_ip_resolve']) {
+                $records = dns_get_record($uri->getHost(), DNS_A);
+                if (!isset($records[0]['ip'])) {
+                    throw new ConnectException(sprintf("Could not resolve IPv4 address for host '%s'", $uri->getHost()), $request);
+                }
+                $uri = $uri->withHost($records[0]['ip']);
+            } elseif ('v6' === $options['force_ip_resolve']) {
+                $records = dns_get_record($uri->getHost(), DNS_AAAA);
+                if (!isset($records[0]['ipv6'])) {
+                    throw new ConnectException(sprintf("Could not resolve IPv6 address for host '%s'", $uri->getHost()), $request);
+                }
+                $uri = $uri->withHost('[' . $records[0]['ipv6'] . ']');
+            }
+        }
+
+        return $uri;
+    }
+
+    private function getDefaultContext(RequestInterface $request)
+    {
+        $headers = '';
+        foreach ($request->getHeaders() as $name => $value) {
+            foreach ($value as $val) {
+                $headers .= "$name: $val\r\n";
+            }
+        }
+
+        $context = [
+            'http' => [
+                'method'           => $request->getMethod(),
+                'header'           => $headers,
+                'protocol_version' => $request->getProtocolVersion(),
+                'ignore_errors'    => true,
+                'follow_location'  => 0,
+            ],
+        ];
+
+        $body = (string) $request->getBody();
+
+        if (!empty($body)) {
+            $context['http']['content'] = $body;
+            if (!$request->hasHeader('Content-Type')) {
+                $context['http']['header'] .= "Content-Type:\r\n";
+            }
+        }
+
+        $context['http']['header'] = rtrim($context['http']['header']);
+
+        return $context;
+    }
+
+    private function add_proxy(RequestInterface $request, &$options, $value, &$params)
+    {
+        if (!is_array($value)) {
+            $options['http']['proxy'] = $value;
+        } else {
+            $scheme = $request->getUri()->getScheme();
+            if (isset($value[$scheme])) {
+                if (!isset($value['no'])
+                    || !\GuzzleHttp\is_host_in_noproxy(
+                        $request->getUri()->getHost(),
+                        $value['no']
+                    )
+                ) {
+                    $options['http']['proxy'] = $value[$scheme];
+                }
+            }
+        }
+    }
+
+    private function add_timeout(RequestInterface $request, &$options, $value, &$params)
+    {
+        if ($value > 0) {
+            $options['http']['timeout'] = $value;
+        }
+    }
+
+    private function add_verify(RequestInterface $request, &$options, $value, &$params)
+    {
+        if ($value === true) {
+            if (PHP_VERSION_ID < 50600) {
+                $options['ssl']['cafile'] = \GuzzleHttp\default_ca_bundle();
+            }
+        } elseif (is_string($value)) {
+            $options['ssl']['cafile'] = $value;
+            if (!file_exists($value)) {
+                throw new \RuntimeException("SSL CA bundle not found: $value");
+            }
+        } elseif ($value === false) {
+            $options['ssl']['verify_peer'] = false;
+            $options['ssl']['verify_peer_name'] = false;
+            return;
+        } else {
+            throw new \InvalidArgumentException('Invalid verify request option');
+        }
+
+        $options['ssl']['verify_peer'] = true;
+        $options['ssl']['verify_peer_name'] = true;
+        $options['ssl']['allow_self_signed'] = false;
+    }
+
+    private function add_cert(RequestInterface $request, &$options, $value, &$params)
+    {
+        if (is_array($value)) {
+            $options['ssl']['passphrase'] = $value[1];
+            $value = $value[0];
+        }
+
+        if (!file_exists($value)) {
+            throw new \RuntimeException("SSL certificate not found: {$value}");
+        }
+
+        $options['ssl']['local_cert'] = $value;
+    }
+
+    private function add_progress(RequestInterface $request, &$options, $value, &$params)
+    {
+        $this->addNotification(
+            $params,
+            function ($code, $a, $b, $c, $transferred, $total) use ($value) {
+                if ($code == STREAM_NOTIFY_PROGRESS) {
+                    $value($total, $transferred, null, null);
+                }
+            }
+        );
+    }
+
+    private function add_debug(RequestInterface $request, &$options, $value, &$params)
+    {
+        if ($value === false) {
+            return;
+        }
+
+        static $map = [
+            STREAM_NOTIFY_CONNECT       => 'CONNECT',
+            STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED',
+            STREAM_NOTIFY_AUTH_RESULT   => 'AUTH_RESULT',
+            STREAM_NOTIFY_MIME_TYPE_IS  => 'MIME_TYPE_IS',
+            STREAM_NOTIFY_FILE_SIZE_IS  => 'FILE_SIZE_IS',
+            STREAM_NOTIFY_REDIRECTED    => 'REDIRECTED',
+            STREAM_NOTIFY_PROGRESS      => 'PROGRESS',
+            STREAM_NOTIFY_FAILURE       => 'FAILURE',
+            STREAM_NOTIFY_COMPLETED     => 'COMPLETED',
+            STREAM_NOTIFY_RESOLVE       => 'RESOLVE',
+        ];
+        static $args = ['severity', 'message', 'message_code',
+            'bytes_transferred', 'bytes_max'];
+
+        $value = \GuzzleHttp\debug_resource($value);
+        $ident = $request->getMethod() . ' ' . $request->getUri()->withFragment('');
+        $this->addNotification(
+            $params,
+            function () use ($ident, $value, $map, $args) {
+                $passed = func_get_args();
+                $code = array_shift($passed);
+                fprintf($value, '<%s> [%s] ', $ident, $map[$code]);
+                foreach (array_filter($passed) as $i => $v) {
+                    fwrite($value, $args[$i] . ': "' . $v . '" ');
+                }
+                fwrite($value, "\n");
+            }
+        );
+    }
+
+    private function addNotification(array &$params, callable $notify)
+    {
+        if (!isset($params['notification'])) {
+            $params['notification'] = $notify;
+        } else {
+            $params['notification'] = $this->callArray([
+                $params['notification'],
+                $notify
+            ]);
+        }
+    }
+
+    private function callArray(array $functions)
+    {
+        return function () use ($functions) {
+            $args = func_get_args();
+            foreach ($functions as $fn) {
+                call_user_func_array($fn, $args);
+            }
+        };
+    }
+}

+ 23 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Common/ToArrayInterface.php

@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Common;
+
+interface ToArrayInterface
+{
+	public function toArray();
+}

+ 83 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Common/V2Transform.php

@@ -0,0 +1,83 @@
+<?php
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Common;
+
+use Obs\ObsClient;
+use Obs\Internal\Resource\V2Constants;
+
+class V2Transform implements ITransform{
+    private static $instance;
+    
+    private function __construct(){}
+    
+    public static function getInstance() {
+        if (!(self::$instance instanceof V2Transform)) {
+            self::$instance = new V2Transform();
+        }
+        return self::$instance;
+    }
+     
+    public function transform($sign, $para) {
+        if ($sign === 'storageClass') {
+            $para = $this->transStorageClass($para);
+        } else if ($sign === 'aclHeader') {
+            $para = $this->transAclHeader($para);
+        } else if ($sign === 'aclUri') {
+            $para = $this->transAclGroupUri($para);
+        } else if ($sign == 'event') {
+            $para = $this->transNotificationEvent($para);
+        }
+        return $para;
+    }
+    
+    private function transStorageClass($para) {
+        $search = array(ObsClient::StorageClassStandard, ObsClient::StorageClassWarm, ObsClient::StorageClassCold);
+        $repalce = array('STANDARD', 'STANDARD_IA', 'GLACIER');
+        $para = str_replace($search, $repalce, $para);
+        return $para;
+    }
+    
+    private function transAclHeader($para) {
+        if ($para === ObsClient::AclPublicReadDelivered || $para === ObsClient::AclPublicReadWriteDelivered) {
+            $para = null;
+        }
+        return $para;                    
+    }
+    
+    private function transAclGroupUri($para) {
+        if ($para === ObsClient::GroupAllUsers) {
+            $para = V2Constants::GROUP_ALL_USERS_PREFIX . $para;
+        } else if ($para === ObsClient::GroupAuthenticatedUsers) {
+            $para = V2Constants::GROUP_AUTHENTICATED_USERS_PREFIX . $para; 
+        } else if ($para === ObsClient::GroupLogDelivery) {
+            $para = V2Constants::GROUP_LOG_DELIVERY_PREFIX . $para;
+        } else if ($para === ObsClient::AllUsers) {
+            $para = V2Constants::GROUP_ALL_USERS_PREFIX . ObsClient::GroupAllUsers;
+        }
+        return $para;
+    }
+    
+    private function transNotificationEvent($para) {
+        $pos = strpos($para, 's3:');
+        if ($pos === false || $pos !== 0) {
+            $para = 's3:' . $para;
+        }
+        return $para;
+    }
+}
+
+

+ 455 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/GetResponseTrait.php

@@ -0,0 +1,455 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal;
+use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\Psr7\Response;
+use GuzzleHttp\Exception\RequestException;
+use Obs\ObsException;
+use Obs\Internal\Common\Model;
+use Obs\Internal\Resource\Constants;
+use Obs\Log\ObsLog;
+use Psr\Http\Message\StreamInterface;
+use Obs\Internal\Common\CheckoutStream;
+
+trait GetResponseTrait
+{
+
+	protected $exceptionResponseMode = true;
+	
+	protected $chunkSize = 65536;
+	
+	protected function isClientError(Response $response)
+	{
+		return $response -> getStatusCode() >= 400 && $response -> getStatusCode() < 500;
+	}
+	
+	protected function parseXmlByType($searchPath, $key, &$value, $xml, $prefix)
+	{	
+		$type = 'string';
+		
+		if(isset($value['sentAs'])){
+			$key = $value['sentAs'];
+		}
+		
+		if($searchPath === null){
+			$searchPath = '//'.$prefix.$key;
+		}
+		
+		if(isset($value['type'])){
+			$type = $value['type'];
+			if($type === 'array'){
+				$items = $value['items'];
+				if(isset($value['wrapper'])){
+				    $paths = explode('/', $searchPath);
+				    $size = count($paths);
+				    if ($size > 1) {
+				        $end = $paths[$size - 1];
+				        $paths[$size - 1] = $value['wrapper'];
+				        $paths[] = $end;
+				        $searchPath = implode('/', $paths) .'/' . $prefix;
+				    }
+				}
+				
+				$array = [];
+				if(!isset($value['data']['xmlFlattened'])){
+					$pkey = isset($items['sentAs']) ? $items['sentAs'] : $items['name'];
+					$_searchPath = $searchPath .'/' . $prefix .$pkey;
+				}else{
+					$pkey = $key;
+					$_searchPath = $searchPath;
+				}
+				if($result = $xml -> xpath($_searchPath)){
+					if(is_array($result)){
+						foreach ($result as $subXml){
+							$subXml = simplexml_load_string($subXml -> asXML());
+							$subPrefix = $this->getXpathPrefix($subXml);
+							$array[] = $this->parseXmlByType('//'.$subPrefix. $pkey, $pkey, $items, $subXml, $subPrefix);
+						}
+					}
+				}
+				return $array;
+			}else if($type === 'object'){
+				$properties = $value['properties'];
+				$array = [];
+				foreach ($properties as $pkey => $pvalue){
+					$name = isset($pvalue['sentAs']) ? $pvalue['sentAs'] : $pkey;
+					$array[$pkey] = $this->parseXmlByType($searchPath.'/' . $prefix .$name, $name, $pvalue, $xml, $prefix);
+				}
+				return $array;
+			}
+		}
+		
+		if($result = $xml -> xpath($searchPath)){
+			if($type === 'boolean'){
+				return strval($result[0]) !== 'false';
+			}else if($type === 'numeric' || $type === 'float'){
+				return floatval($result[0]);
+			}else if($type === 'int' || $type === 'integer'){
+				return intval($result[0]);
+			}else{
+				return strval($result[0]);
+			}
+		}else{
+			if($type === 'boolean'){
+				return false;
+			}else if($type === 'numeric' || $type === 'float' || $type === 'int' || $type === 'integer'){
+				return null;
+			}else{
+				return '';
+			}
+		}
+	}
+
+	private function isJsonResponse($response) {
+	    return $response -> getHeaderLine('content-type') === 'application/json';
+    }
+
+	private function parseCommonHeaders($model, $response){
+	    $constants = Constants::selectConstants($this -> signature);
+	    foreach($constants::COMMON_HEADERS as $key => $value){
+			$model[$value] = $response -> getHeaderLine($key);
+		}
+	}
+	
+	protected function parseItems($responseParameters, $model, $response, $body)
+	{
+		$prefix = '';
+		
+		$this->parseCommonHeaders($model, $response);
+		
+		$closeBody = false;
+		try{
+			foreach ($responseParameters as $key => $value){
+				if(isset($value['location'])){
+					$location = $value['location'];
+					if($location === 'header'){
+						$name = isset($value['sentAs']) ? $value['sentAs'] : $key;
+						$isSet = false;
+						if(isset($value['type'])){
+							$type = $value['type'];
+							if($type === 'object'){
+								$headers = $response -> getHeaders();
+								$temp = [];
+								foreach ($headers as $headerName => $headerValue){
+									if(stripos($headerName, $name) === 0){
+									    $metaKey = rawurldecode(substr($headerName, strlen($name)));
+									    $temp[$metaKey] = rawurldecode($response -> getHeaderLine($headerName));
+									}
+								}
+								$model[$key] = $temp;
+								$isSet = true;
+							}else{
+								if($response -> hasHeader($name)){
+									if($type === 'boolean'){
+										$model[$key] = ($response -> getHeaderLine($name)) !== 'false';
+										$isSet = true;
+									}else if($type === 'numeric' || $type === 'float'){
+										$model[$key] = floatval($response -> getHeaderLine($name));
+										$isSet = true;
+									}else if($type === 'int' || $type === 'integer'){
+										$model[$key] = intval($response -> getHeaderLine($name));
+										$isSet = true;
+									}
+								}
+							}
+						}
+						if(!$isSet){
+							$model[$key] = rawurldecode($response -> getHeaderLine($name));
+						}
+					}else if($location === 'xml' && $body !== null){
+					    if(!isset($xml) && ($xml = simplexml_load_string($body -> getContents()))){
+							$prefix = $this ->getXpathPrefix($xml);
+						}
+						$closeBody = true;
+						$model[$key] = $this -> parseXmlByType(null, $key,$value, $xml, $prefix);
+					}else if($location === 'body' && $body !== null){
+						if(isset($value['type']) && $value['type'] === 'stream'){
+							$model[$key] = $body;
+						}else if (isset($value['type']) && $value['type'] === 'json') {
+                            $jsonBody = trim($body -> getContents());
+                            if ($jsonBody && ($data = json_decode($jsonBody, true))) {
+                                if (is_array($data)) {
+                                    $model[$key] = $data;
+                                } elseif (strlen($data)) {
+                                    ObsLog::commonLog(ERROR, "response body %s, and jsonToArray data is %s",$body, $data);
+                                }
+                            }
+                            $closeBody = true;
+                        } else {
+							$model[$key] = $body -> getContents();
+							$closeBody = true;
+						}
+					}
+				}
+			}
+		}finally {
+			if($closeBody && $body !== null){
+				$body -> close();
+			}
+		}
+	}
+	
+	private function writeFile($filePath, StreamInterface &$body, $contentLength)
+	{
+		$filePath = iconv('UTF-8', 'GBK', $filePath);
+		if(is_string($filePath) && $filePath !== '')
+		{
+			$fp = null;
+			$dir = dirname($filePath);
+			try{
+				if(!is_dir($dir))
+				{
+					mkdir($dir,0755,true);
+				}
+				
+				if(($fp = fopen($filePath, 'w')))
+				{
+					while(!$body->eof())
+					{
+						$str = $body->read($this->chunkSize);
+						fwrite($fp, $str);
+					}
+					fflush($fp);
+					ObsLog::commonLog(DEBUG, "write file %s ok",$filePath);
+				}
+				else{
+					ObsLog::commonLog(ERROR, "open file error,file path:%s",$filePath);
+				}
+			}finally{
+				if($fp){
+					fclose($fp);
+				}
+				$body->close();
+				$body = null;
+			}
+		}
+	}
+	
+	private function parseXmlToException($body, $obsException){
+		try{
+			$xmlErrorBody = trim($body -> getContents());
+			if($xmlErrorBody && ($xml = simplexml_load_string($xmlErrorBody))){
+				$prefix = $this->getXpathPrefix($xml);
+				if ($tempXml = $xml->xpath('//'.$prefix . 'Code')) {
+					$obsException-> setExceptionCode(strval($tempXml[0]));
+				}
+				if ($tempXml = $xml->xpath('//'.$prefix . 'RequestId')) {
+					$obsException-> setRequestId(strval($tempXml[0]));
+				}
+				if ($tempXml = $xml->xpath('//'.$prefix . 'Message')) {
+					$obsException-> setExceptionMessage(strval($tempXml[0]));
+				}
+				if ($tempXml = $xml->xpath('//'.$prefix . 'HostId')) {
+					$obsException -> setHostId(strval($tempXml[0]));
+				}
+			}
+		}finally{
+			$body -> close();
+		}
+	}
+
+	private function parseJsonToException($body, $obsException) {
+        try {
+            $jsonErrorBody = trim($body -> getContents());
+            if ($jsonErrorBody && ($data = json_decode($jsonErrorBody, true))) {
+                if (is_array($data)) {
+                    if ($data['request_id']) {
+                        $obsException -> setRequestId(strval($data['request_id']));
+                    }
+                    if ($data['code']) {
+                        $obsException -> setExceptionCode(strval($data['code']));
+                    }
+                    if ($data['message']) {
+                        $obsException -> setExceptionMessage(strval($data['message']));
+                    }
+                } elseif (strlen($data)) {
+                    ObsLog::commonLog(ERROR, "response body %s, and jsonToArray data is %s",$body, $data);
+                    $obsException-> setExceptionMessage("Invalid response data,since it is not json data");
+                }
+            }
+        } finally {
+            $body -> close();
+        }
+    }
+
+    private function parseJsonToModel($body, $model) {
+	    try{
+	        $jsonErrorBody = trim($body -> getContents());
+	        if ($jsonErrorBody && ($jsonArray = json_decode($jsonErrorBody, true))) {
+	            if (is_array($jsonArray)) {
+                    if ($jsonArray['request_id']) {
+                        $model['RequestId'] = strval($jsonArray['request_id']);
+                    }
+                    if ($jsonArray['code']) {
+                        $model['Code'] = strval($jsonArray['code']);
+                    }
+                    if ($jsonArray['message']) {
+                        $model['Message']  = strval($jsonArray['message']);
+                    }
+                } elseif (strlen($jsonArray)) {
+                    ObsLog::commonLog(ERROR, "response body %s, and jsonToArray data is %s",$body, $jsonArray);
+                    $model['Message'] = "Invalid response data,since it is not json data";
+                }
+            }
+        } finally {
+            $body -> close();
+        }
+    }
+	
+	private function parseXmlToModel($body, $model){
+		try{
+			$xmlErrorBody = trim($body -> getContents());
+			if($xmlErrorBody && ($xml = simplexml_load_string($xmlErrorBody))){
+				$prefix = $this->getXpathPrefix($xml);
+				if ($tempXml = $xml->xpath('//'.$prefix . 'Code')) {
+					$model['Code'] = strval($tempXml[0]);
+				}
+				if ($tempXml = $xml->xpath('//'.$prefix . 'RequestId')) {
+					$model['RequestId'] = strval($tempXml[0]);
+				}
+				
+				if ($tempXml = $xml->xpath('//'.$prefix . 'HostId')) {
+					$model['HostId'] = strval($tempXml[0]);
+				}
+				if ($tempXml = $xml->xpath('//'.$prefix . 'Resource')) {
+					$model['Resource'] = strval($tempXml[0]);
+				}
+				
+				if ($tempXml = $xml->xpath('//'.$prefix . 'Message')) {
+					$model['Message']  = strval($tempXml[0]);
+				}
+			}
+		}finally {
+			$body -> close();
+		}
+	}
+	
+	protected function parseResponse(Model $model, Request $request, Response $response, array $requestConfig)
+	{
+		$statusCode = $response -> getStatusCode();
+		$expectedLength = $response -> getHeaderLine('content-length');
+        $responseContentType = $response -> getHeaderLine('content-type');
+
+		$expectedLength = is_numeric($expectedLength) ? floatval($expectedLength) : null;
+		
+		$body = new CheckoutStream($response->getBody(), $expectedLength);
+		
+		if($statusCode >= 300){
+			if($this-> exceptionResponseMode){
+				$obsException= new ObsException();
+				$obsException-> setRequest($request);
+				$obsException-> setResponse($response);
+				$obsException-> setExceptionType($this->isClientError($response) ? 'client' : 'server');
+				if ($responseContentType === 'application/json') {
+				    $this->parseJsonToException($body, $obsException);
+                } else {
+                    $this->parseXmlToException($body, $obsException);
+                }
+				throw $obsException;
+			}else{
+				$this->parseCommonHeaders($model, $response);
+                if ($responseContentType === 'application/json') {
+                    $this->parseJsonToModel($body, $model);
+                } else {
+                    $this->parseXmlToModel($body, $model);
+                }
+			}
+			
+		}else{
+			if(!empty($model)){
+				foreach ($model as $key => $value){
+					if($key === 'method'){
+						continue;
+					}
+					if(isset($value['type']) && $value['type'] === 'file'){
+					    $this->writeFile($value['value'], $body, $expectedLength);
+					}
+					$model[$key] = $value['value'];
+				}
+			}
+			
+			if(isset($requestConfig['responseParameters'])){
+				$responseParameters = $requestConfig['responseParameters'];
+				if(isset($responseParameters['type']) && $responseParameters['type'] === 'object'){
+					$responseParameters = $responseParameters['properties'];
+				}
+				$this->parseItems($responseParameters, $model, $response, $body);
+			}
+		}
+		
+		$model['HttpStatusCode'] = $statusCode;
+		$model['Reason'] = $response -> getReasonPhrase();
+	}
+	
+	protected function getXpathPrefix($xml)
+	{
+		$namespaces = $xml -> getDocNamespaces();
+		if (isset($namespaces[''])) {
+			$xml->registerXPathNamespace('ns', $namespaces['']);
+			$prefix = 'ns:';
+		} else {
+			$prefix = '';
+		}
+		return $prefix;
+	}
+	
+	protected function buildException(Request $request, RequestException $exception, $message)
+	{
+		$response = $exception-> hasResponse() ? $exception-> getResponse() : null;
+		$obsException= new ObsException($message ? $message : $exception-> getMessage());
+		$obsException-> setExceptionType('client');
+		$obsException-> setRequest($request);
+		if($response){
+			$obsException-> setResponse($response);
+			$obsException-> setExceptionType($this->isClientError($response) ? 'client' : 'server');
+			if ($this->isJsonResponse($response)) {
+                $this->parseJsonToException($response -> getBody(), $obsException);
+            } else {
+                $this->parseXmlToException($response -> getBody(), $obsException);
+            }
+    		if ($obsException->getRequestId() === null) {
+    		    $prefix = strcasecmp($this->signature, 'obs' ) === 0 ? 'x-obs-' : 'x-amz-';
+    		    $requestId = $response->getHeaderLine($prefix . 'request-id');
+    		    $obsException->setRequestId($requestId); 
+    		}
+		}
+		return $obsException;
+	}
+	
+	protected function parseExceptionAsync(Request $request, RequestException $exception, $message=null)
+	{
+		return $this->buildException($request, $exception, $message);
+	}
+	
+	protected function parseException(Model $model, Request $request, RequestException $exception, $message=null)
+	{
+		$response = $exception-> hasResponse() ? $exception-> getResponse() : null;
+		if($this-> exceptionResponseMode){
+			throw $this->buildException($request, $exception, $message);
+		}else{
+			if($response){
+				$model['HttpStatusCode'] = $response -> getStatusCode();
+				$model['Reason'] = $response -> getReasonPhrase();
+				$this->parseXmlToModel($response -> getBody(), $model);
+			}else{
+				$model['HttpStatusCode'] = -1;
+				$model['Message'] = $exception -> getMessage();
+			}
+		}
+	}
+}

+ 123 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Resource/Constants.php

@@ -0,0 +1,123 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Resource;
+
+class Constants {
+    const ALLOWED_RESOURCE_PARAMTER_NAMES = [ 
+            'acl',
+            'policy',
+            'torrent',
+            'logging',
+            'location',
+            'storageinfo',
+            'quota',
+            'storagepolicy',
+            'requestpayment',
+            'versions',
+            'versioning',
+            'versionid',
+            'uploads',
+            'uploadid',
+            'partnumber',
+            'website',
+            'notification',
+            'lifecycle',
+            'deletebucket',
+            'delete',
+            'cors',
+            'restore',
+            'tagging',
+            'response-content-type',
+            'response-content-language',
+            'response-expires',
+            'response-cache-control',
+            'response-content-disposition',
+            'response-content-encoding',
+            'x-image-process',
+
+            'backtosource',
+            'storageclass',
+            'replication',
+            'append',
+            'position',
+            'x-oss-process'
+    ];
+    const ALLOWED_REQUEST_HTTP_HEADER_METADATA_NAMES = [ 
+            'content-type',
+            'content-md5',
+            'content-length',
+            'content-language',
+            'expires',
+            'origin',
+            'cache-control',
+            'content-disposition',
+            'content-encoding',
+            'access-control-request-method',
+            'access-control-request-headers',
+            'x-default-storage-class',
+            'location',
+            'date',
+            'etag',
+            'range',
+            'host',
+            'if-modified-since',
+            'if-unmodified-since',
+            'if-match',
+            'if-none-match',
+            'last-modified',
+            'content-range',
+
+            'success-action-redirect'
+    ];
+    const ALLOWED_RESPONSE_HTTP_HEADER_METADATA_NAMES = [ 
+            'content-type',
+            'content-md5',
+            'content-length',
+            'content-language',
+            'expires',
+            'origin',
+            'cache-control',
+            'content-disposition',
+            'content-encoding',
+            'x-default-storage-class',
+            'location',
+            'date',
+            'etag',
+            'host',
+            'last-modified',
+            'content-range',
+            'x-reserved',
+            'access-control-allow-origin',
+            'access-control-allow-headers',
+            'access-control-max-age',
+            'access-control-allow-methods',
+            'access-control-expose-headers',
+            'connection'
+    ];
+    
+    public static function selectConstants($signature) {
+        $signature = (strcasecmp ( $signature, 'obs' ) === 0) ? 'OBS' : 'V2';
+        return __NAMESPACE__ . '\\' . $signature . 'Constants';
+    }
+    
+    public static function selectRequestResource($signature) {
+        $signature = (strcasecmp ( $signature, 'obs' ) === 0) ? 'OBS' : 'V2';
+        return (__NAMESPACE__ . '\\' . $signature . 'RequestResource');
+    }
+
+}

+ 35 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Resource/OBSConstants.php

@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Resource;
+
+class OBSConstants extends Constants {
+    const FLAG = 'OBS';
+    const METADATA_PREFIX = 'x-obs-meta-';
+    const HEADER_PREFIX = 'x-obs-';
+    const ALTERNATIVE_DATE_HEADER = 'x-obs-date';
+    const SECURITY_TOKEN_HEAD = 'x-obs-security-token';
+    const TEMPURL_AK_HEAD = 'AccessKeyId';
+    
+    const COMMON_HEADERS = [
+        'content-length' => 'ContentLength',
+        'date' => 'Date',
+        'x-obs-request-id' => 'RequestId',
+        'x-obs-id-2' => 'Id2',
+        'x-reserved' => 'Reserved'
+    ];
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 4202 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Resource/OBSRequestResource.php


+ 38 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Resource/V2Constants.php

@@ -0,0 +1,38 @@
+<?php
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Resource;
+
+class V2Constants extends Constants {
+    const FLAG = 'AWS';
+    const METADATA_PREFIX = 'x-amz-meta-';
+    const HEADER_PREFIX = 'x-amz-';
+    const ALTERNATIVE_DATE_HEADER = 'x-amz-date';
+    const SECURITY_TOKEN_HEAD = 'x-amz-security-token';
+    const TEMPURL_AK_HEAD = 'AWSAccessKeyId';
+    
+    const GROUP_ALL_USERS_PREFIX = 'http://acs.amazonaws.com/groups/global/';
+    const GROUP_AUTHENTICATED_USERS_PREFIX = 'http://acs.amazonaws.com/groups/global/';
+    const GROUP_LOG_DELIVERY_PREFIX = 'http://acs.amazonaws.com/groups/s3/';
+    
+    const COMMON_HEADERS = [
+        'content-length' => 'ContentLength',
+        'date' => 'Date',
+        'x-amz-request-id' => 'RequestId',
+        'x-amz-id-2' => 'Id2',
+        'x-reserved' => 'Reserved'
+    ];
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 4020 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Resource/V2RequestResource.php


+ 726 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/SendRequestTrait.php

@@ -0,0 +1,726 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal;
+
+use GuzzleHttp\Psr7;
+use Obs\Log\ObsLog;
+use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\Psr7\Response;
+use GuzzleHttp\Exception\RequestException;
+use GuzzleHttp\Exception\ConnectException;
+use Obs\Internal\Common\Model;
+use Obs\Internal\Resource\V2Constants;
+use Obs\ObsException;
+use Obs\Internal\Signature\V4Signature;
+use Obs\Internal\Signature\DefaultSignature;
+use GuzzleHttp\Client;
+use Obs\Internal\Resource\Constants;
+use Psr\Http\Message\StreamInterface;
+use Obs\Internal\Resource\V2RequestResource;
+
+trait SendRequestTrait
+{
+	protected $ak;
+	
+	protected $sk;
+	
+	protected $securityToken = false;
+	
+	protected $endpoint = '';
+	
+	protected $pathStyle = false;
+	
+	protected $region = 'region';
+	
+	protected $signature = 'obs';
+	
+	protected $sslVerify = false;
+	
+	protected $maxRetryCount = 3;
+	
+	protected $timeout = 0;
+	
+	protected $socketTimeout = 60; 
+	
+	protected $connectTimeout = 60;
+
+	protected $isCname = false;
+	
+	/** @var Client */
+	protected $httpClient;
+	
+	public function createSignedUrl(array $args=[]){
+	    if (strcasecmp($this -> signature, 'v4') === 0) {
+	        return $this -> createV4SignedUrl($args);
+	    }
+	    return $this->createCommonSignedUrl($this->signature,$args);
+	}
+	
+	public function createV2SignedUrl(array $args=[]) {
+	    return $this->createCommonSignedUrl( 'v2',$args);
+	}
+	
+	private function createCommonSignedUrl(string $signature,array $args=[]) {
+	    if(!isset($args['Method'])){
+	        $obsException = new ObsException('Method param must be specified, allowed values: GET | PUT | HEAD | POST | DELETE | OPTIONS');
+	        $obsException-> setExceptionType('client');
+	        throw $obsException;
+	    }
+	    $method = strval($args['Method']);
+	    $bucketName = isset($args['Bucket'])? strval($args['Bucket']): null;
+	    $objectKey =  isset($args['Key'])? strval($args['Key']): null;
+	    $specialParam = isset($args['SpecialParam'])? strval($args['SpecialParam']): null;
+	    $expires = isset($args['Expires']) && is_numeric($args['Expires']) ? intval($args['Expires']): 300;
+	    
+	    $headers = [];
+	    if(isset($args['Headers']) && is_array($args['Headers']) ){
+	        foreach ($args['Headers'] as $key => $val){
+	            if(is_string($key) && $key !== ''){
+	                $headers[$key] = $val;
+	            }
+	        }
+	    }
+
+
+	    
+	    $queryParams = [];
+	    if(isset($args['QueryParams']) && is_array($args['QueryParams']) ){
+	        foreach ($args['QueryParams'] as $key => $val){
+	            if(is_string($key) && $key !== ''){
+    	            $queryParams[$key] = $val;
+	            }
+	        }
+	    }
+	    
+	    $constants = Constants::selectConstants($signature);
+	    if($this->securityToken && !isset($queryParams[$constants::SECURITY_TOKEN_HEAD])){
+	        $queryParams[$constants::SECURITY_TOKEN_HEAD] = $this->securityToken;
+	    }
+	    
+	    $sign = new DefaultSignature($this->ak, $this->sk, $this->pathStyle, $this->endpoint, $method, $this->signature, $this->securityToken, $this->isCname);
+	    
+	    $url = parse_url($this->endpoint);
+	    $host = $url['host'];
+	    
+	    $result = '';
+	    
+	    if($bucketName){
+	        if($this-> pathStyle){
+	            $result = '/' . $bucketName;
+	        }else{
+	            $host = $this->isCname ? $host : $bucketName . '.' . $host;
+	        }
+	    }
+
+	    $headers['Host'] = $host;
+	    
+	    if($objectKey){
+	        $objectKey = $sign ->urlencodeWithSafe($objectKey);
+	        $result .= '/' . $objectKey;
+	    }
+	    
+	    $result .= '?';
+	    
+	    if($specialParam){
+	        $queryParams[$specialParam] = '';
+	    }
+	    
+	    $queryParams[$constants::TEMPURL_AK_HEAD] = $this->ak;
+	    
+	    
+	    if(!is_numeric($expires) || $expires < 0){
+	        $expires = 300;
+	    }
+	    $expires = intval($expires) + intval(microtime(true));
+	    
+	    $queryParams['Expires'] = strval($expires);
+	    
+	    $_queryParams = [];
+	    
+	    foreach ($queryParams as $key => $val){
+	        $key = $sign -> urlencodeWithSafe($key);
+	        $val = $sign -> urlencodeWithSafe($val);
+	        $_queryParams[$key] = $val;
+	        $result .= $key;
+	        if($val){
+	            $result .= '=' . $val;
+	        }
+	        $result .= '&';
+	    }
+	    
+	    $canonicalstring = $sign ->makeCanonicalstring($method, $headers, $_queryParams, $bucketName, $objectKey, $expires);
+	    $signatureContent = base64_encode(hash_hmac('sha1', $canonicalstring, $this->sk, true));
+	    
+	    $result .= 'Signature=' . $sign->urlencodeWithSafe($signatureContent);
+	    
+	    $model = new Model();
+	    $model['ActualSignedRequestHeaders'] = $headers;
+	    $model['SignedUrl'] = $url['scheme'] . '://' . $host . ':' . (isset($url['port']) ? $url['port'] : (strtolower($url['scheme']) === 'https' ? '443' : '80')) . $result;
+	    return $model;
+	}
+	
+	public function createV4SignedUrl(array $args=[]){
+		if(!isset($args['Method'])){
+			$obsException= new ObsException('Method param must be specified, allowed values: GET | PUT | HEAD | POST | DELETE | OPTIONS');
+			$obsException-> setExceptionType('client');
+			throw $obsException;
+		}
+		$method = strval($args['Method']);
+		$bucketName = isset($args['Bucket'])? strval($args['Bucket']): null;
+		$objectKey =  isset($args['Key'])? strval($args['Key']): null;
+		$specialParam = isset($args['SpecialParam'])? strval($args['SpecialParam']): null;
+		$expires = isset($args['Expires']) && is_numeric($args['Expires']) ? intval($args['Expires']): 300;
+		$headers = [];
+		if(isset($args['Headers']) && is_array($args['Headers']) ){
+			foreach ($args['Headers'] as $key => $val){
+			    if(is_string($key) && $key !== ''){
+			        $headers[$key] = $val;
+			    }
+			}
+		}
+		
+		$queryParams = [];
+		if(isset($args['QueryParams']) && is_array($args['QueryParams']) ){
+			foreach ($args['QueryParams'] as $key => $val){
+			    if(is_string($key) && $key !== ''){
+			        $queryParams[$key] = $val;
+			    }
+			}
+		}
+		
+		if($this->securityToken && !isset($queryParams['x-amz-security-token'])){
+		    $queryParams['x-amz-security-token'] = $this->securityToken;
+		}
+		
+		$v4 = new V4Signature($this->ak, $this->sk, $this->pathStyle, $this->endpoint, $this->region, $method, $this->signature, $this->securityToken, $this->isCname);
+		
+		$url = parse_url($this->endpoint);
+		$host = $url['host'];
+		
+		$result = '';
+		
+		if($bucketName){
+			if($this-> pathStyle){
+				$result = '/' . $bucketName;
+			}else{
+				$host = $this->isCname ? $host : $bucketName . '.' . $host;
+			}
+		}
+
+        $headers['Host'] = $host;
+		
+		if($objectKey){
+			$objectKey = $v4 -> urlencodeWithSafe($objectKey);
+			$result .= '/' . $objectKey;
+		}
+		
+		$result .= '?';
+		
+		if($specialParam){
+			$queryParams[$specialParam] = '';
+		}
+		
+		if(!is_numeric($expires) || $expires < 0){
+			$expires = 300;
+		}
+		
+		$expires = strval($expires);
+		
+		$date = isset($headers['date']) ? $headers['date'] : (isset($headers['Date']) ? $headers['Date'] : null);
+		
+		$timestamp = $date ? date_create_from_format('D, d M Y H:i:s \G\M\T', $date, new \DateTimeZone ('UTC')) -> getTimestamp()
+			:time();
+		
+		$longDate = gmdate('Ymd\THis\Z', $timestamp);
+		$shortDate = substr($longDate, 0, 8);
+		
+		$headers['host'] = $host;
+		if(isset($url['port'])){
+		    $port = $url['port'];
+		    if($port !== 443 && $port !== 80){
+		        $headers['host'] = $headers['host'] . ':' . $port;
+		    }
+		}
+		
+		$signedHeaders = $v4 -> getSignedHeaders($headers);
+		
+		$queryParams['X-Amz-Algorithm'] = 'AWS4-HMAC-SHA256';
+		$queryParams['X-Amz-Credential'] = $v4 -> getCredential($shortDate);
+		$queryParams['X-Amz-Date'] = $longDate;
+		$queryParams['X-Amz-Expires'] = $expires;
+		$queryParams['X-Amz-SignedHeaders'] = $signedHeaders;
+		
+		$_queryParams = [];
+		
+		foreach ($queryParams as $key => $val){
+			$key = rawurlencode($key);
+			$val = rawurlencode($val);
+			$_queryParams[$key] = $val;
+			$result .= $key;
+			if($val){
+				$result .= '=' . $val;
+			}
+			$result .= '&';
+		}
+		
+		$canonicalstring = $v4 -> makeCanonicalstring($method, $headers, $_queryParams, $bucketName, $objectKey, $signedHeaders, 'UNSIGNED-PAYLOAD');
+		
+		$signatureContent = $v4 -> getSignature($canonicalstring, $longDate, $shortDate);
+		
+		$result .= 'X-Amz-Signature=' . $v4 -> urlencodeWithSafe($signatureContent);
+		
+		$model = new Model();
+		$model['ActualSignedRequestHeaders'] = $headers;
+		$model['SignedUrl'] = $url['scheme'] . '://' . $host . ':' . (isset($url['port']) ? $url['port'] : (strtolower($url['scheme']) === 'https' ? '443' : '80')) . $result;
+		return $model;
+	}
+	
+	public function createPostSignature(array $args=[]) {
+	    if (strcasecmp($this -> signature, 'v4') === 0) {
+	        return $this -> createV4PostSignature($args);
+	    }
+	    
+	    $bucketName = isset($args['Bucket'])? strval($args['Bucket']): null;
+	    $objectKey =  isset($args['Key'])? strval($args['Key']): null;
+	    $expires = isset($args['Expires']) && is_numeric($args['Expires']) ? intval($args['Expires']): 300;
+	    
+	    $formParams = [];
+	    
+	    if(isset($args['FormParams']) && is_array($args['FormParams'])){
+	        foreach ($args['FormParams'] as $key => $val){
+	            $formParams[$key] = $val;
+	        }
+	    }
+	    
+	    $constants = Constants::selectConstants($this -> signature);
+	    if($this->securityToken && !isset($formParams[$constants::SECURITY_TOKEN_HEAD])){
+	        $formParams[$constants::SECURITY_TOKEN_HEAD] = $this->securityToken;
+	    }
+	    
+	    $timestamp = time();
+	    $expires = gmdate('Y-m-d\TH:i:s\Z', $timestamp + $expires);
+	    
+	    if($bucketName){
+	        $formParams['bucket'] = $bucketName;
+	    }
+	    
+	    if($objectKey){
+	        $formParams['key'] = $objectKey;
+	    }
+	    
+	    $policy = [];
+	    
+	    $policy[] = '{"expiration":"';
+	    $policy[] = $expires;
+	    $policy[] = '", "conditions":[';
+	    
+	    $matchAnyBucket = true;
+	    $matchAnyKey = true;
+	    
+	    $conditionAllowKeys = ['acl', 'bucket', 'key', 'success_action_redirect', 'redirect', 'success_action_status'];
+	    
+	    foreach($formParams as $key => $val){
+	        if($key){
+	            $key = strtolower(strval($key));
+	            
+	            if($key === 'bucket'){
+	                $matchAnyBucket = false;
+	            }else if($key === 'key'){
+	                $matchAnyKey = false;
+	            }
+	            
+	            if(!in_array($key, Constants::ALLOWED_REQUEST_HTTP_HEADER_METADATA_NAMES) && strpos($key, $constants::HEADER_PREFIX) !== 0 && !in_array($key, $conditionAllowKeys)){
+	                $key = $constants::METADATA_PREFIX . $key;
+	            }
+	            
+	            $policy[] = '{"';
+	            $policy[] = $key;
+	            $policy[] = '":"';
+	            $policy[] = $val !== null ? strval($val) : '';
+	            $policy[] = '"},';
+	        }
+	    }
+	    
+	    if($matchAnyBucket){
+	        $policy[] = '["starts-with", "$bucket", ""],';
+	    }
+	    
+	    if($matchAnyKey){
+	        $policy[] = '["starts-with", "$key", ""],';
+	    }
+	    
+	    $policy[] = ']}';
+	    
+	    $originPolicy = implode('', $policy);
+	    
+	    $policy = base64_encode($originPolicy);
+	    
+	    $signatureContent = base64_encode(hash_hmac('sha1', $policy, $this->sk, true));
+	    
+	    $model = new Model();
+	    $model['OriginPolicy'] = $originPolicy;
+	    $model['Policy'] = $policy;
+	    $model['Signature'] = $signatureContent;
+	    return $model;
+	}
+	
+	public function createV4PostSignature(array $args=[]){
+		$bucketName = isset($args['Bucket'])? strval($args['Bucket']): null;
+		$objectKey =  isset($args['Key'])? strval($args['Key']): null;
+		$expires = isset($args['Expires']) && is_numeric($args['Expires']) ? intval($args['Expires']): 300;
+		
+		$formParams = [];
+		
+		if(isset($args['FormParams']) && is_array($args['FormParams'])){
+			foreach ($args['FormParams'] as $key => $val){
+				$formParams[$key] = $val;
+			}
+		}
+		
+		if($this->securityToken && !isset($formParams['x-amz-security-token'])){
+		    $formParams['x-amz-security-token'] = $this->securityToken;
+		}
+		
+		$timestamp = time();
+		$longDate = gmdate('Ymd\THis\Z', $timestamp);
+		$shortDate = substr($longDate, 0, 8);
+		
+		$credential = sprintf('%s/%s/%s/s3/aws4_request', $this->ak, $shortDate, $this->region);
+		
+		$expires = gmdate('Y-m-d\TH:i:s\Z', $timestamp + $expires);
+		
+		$formParams['X-Amz-Algorithm'] = 'AWS4-HMAC-SHA256';
+		$formParams['X-Amz-Date'] = $longDate;
+		$formParams['X-Amz-Credential'] = $credential;
+		
+		if($bucketName){
+			$formParams['bucket'] = $bucketName;
+		}
+		
+		if($objectKey){
+			$formParams['key'] = $objectKey;
+		}
+		
+		$policy = [];
+		
+		$policy[] = '{"expiration":"';
+		$policy[] = $expires;
+		$policy[] = '", "conditions":[';
+		
+		$matchAnyBucket = true;
+		$matchAnyKey = true;
+		
+		$conditionAllowKeys = ['acl', 'bucket', 'key', 'success_action_redirect', 'redirect', 'success_action_status'];
+		
+		foreach($formParams as $key => $val){
+			if($key){
+				$key = strtolower(strval($key));
+				
+				if($key === 'bucket'){
+					$matchAnyBucket = false;
+				}else if($key === 'key'){
+					$matchAnyKey = false;
+				}
+				
+				if(!in_array($key, Constants::ALLOWED_REQUEST_HTTP_HEADER_METADATA_NAMES) && strpos($key, V2Constants::HEADER_PREFIX) !== 0 && !in_array($key, $conditionAllowKeys)){
+					$key = V2Constants::METADATA_PREFIX . $key;
+				}
+				
+				$policy[] = '{"';
+				$policy[] = $key;
+				$policy[] = '":"';
+				$policy[] = $val !== null ? strval($val) : '';
+				$policy[] = '"},';
+			}
+		}
+		
+		if($matchAnyBucket){
+			$policy[] = '["starts-with", "$bucket", ""],';
+		}
+		
+		if($matchAnyKey){
+			$policy[] = '["starts-with", "$key", ""],';
+		}
+		
+		$policy[] = ']}';
+		
+		$originPolicy = implode('', $policy);
+		
+		$policy = base64_encode($originPolicy);
+		
+		$dateKey = hash_hmac('sha256', $shortDate, 'AWS4' . $this -> sk, true);
+		$regionKey = hash_hmac('sha256', $this->region, $dateKey, true);
+		$serviceKey = hash_hmac('sha256', 's3', $regionKey, true);
+		$signingKey = hash_hmac('sha256', 'aws4_request', $serviceKey, true);
+		$signatureContent = hash_hmac('sha256', $policy, $signingKey);
+		
+		$model = new Model();
+		$model['OriginPolicy'] = $originPolicy;
+		$model['Policy'] = $policy;
+		$model['Algorithm'] = $formParams['X-Amz-Algorithm'];
+		$model['Credential'] = $formParams['X-Amz-Credential'];
+		$model['Date'] = $formParams['X-Amz-Date'];
+		$model['Signature'] = $signatureContent;
+		return $model;
+	}
+	
+	public function __call($originMethod, $args)
+	{
+		$method = $originMethod;
+		
+		$contents = Constants::selectRequestResource($this->signature);
+		$resource = &$contents::$RESOURCE_ARRAY;
+		$async = false;
+		if(strpos($method, 'Async') === (strlen($method) - 5)){
+			$method = substr($method, 0, strlen($method) - 5);
+			$async = true;
+		}
+		
+		if(isset($resource['aliases'][$method])){
+		    $method = $resource['aliases'][$method];
+		}
+		
+		$method = lcfirst($method);
+		
+		
+		$operation = isset($resource['operations'][$method]) ? 
+			$resource['operations'][$method] : null;
+		
+		if(!$operation){
+			ObsLog::commonLog(WARNING, 'unknow method ' . $originMethod);
+			$obsException= new ObsException('unknow method '. $originMethod);
+			$obsException-> setExceptionType('client');
+			throw $obsException;
+		}
+		
+		$start = microtime(true);
+		if(!$async){
+			ObsLog::commonLog(INFO, 'enter method '. $originMethod. '...');
+			$model = new Model();
+			$model['method'] = $method;
+			$params = empty($args) ? [] : $args[0];
+			$this->checkMimeType($method, $params);
+			$this->doRequest($model, $operation, $params);
+			ObsLog::commonLog(INFO, 'obsclient cost ' . round(microtime(true) - $start, 3) * 1000 . ' ms to execute '. $originMethod);
+			unset($model['method']);
+			return $model;
+		}else{
+			if(empty($args) || !(is_callable($callback = $args[count($args) -1]))){
+				ObsLog::commonLog(WARNING, 'async method ' . $originMethod . ' must pass a CallbackInterface as param');
+				$obsException= new ObsException('async method ' . $originMethod . ' must pass a CallbackInterface as param');
+				$obsException-> setExceptionType('client');
+				throw $obsException;
+			}
+			ObsLog::commonLog(INFO, 'enter method '. $originMethod. '...');
+			$params = count($args) === 1 ? [] : $args[0];
+			$this->checkMimeType($method, $params);
+			$model = new Model();
+			$model['method'] = $method;
+			return $this->doRequestAsync($model, $operation, $params, $callback, $start, $originMethod);
+		}
+	}
+	
+	private function checkMimeType($method, &$params){
+		// fix bug that guzzlehttp lib will add the content-type if not set
+		if(($method === 'putObject' || $method === 'initiateMultipartUpload' || $method === 'uploadPart') && (!isset($params['ContentType']) || $params['ContentType'] === null)){
+			if(isset($params['Key'])){
+				try {
+					$params['ContentType'] = Psr7\mimetype_from_filename($params['Key']);
+				} catch (\Throwable $e) {
+					$params['ContentType'] = Psr7\MimeType::fromFilename($params['Key']);
+				}
+			}
+			
+			if((!isset($params['ContentType']) || $params['ContentType'] === null) && isset($params['SourceFile'])){
+				try {
+					$params['ContentType'] = Psr7\mimetype_from_filename($params['SourceFile']);
+				} catch (\Throwable $e) {
+					$params['ContentType'] = Psr7\MimeType::fromFilename($params['SourceFile']);
+				}
+			}
+			
+			if(!isset($params['ContentType']) || $params['ContentType'] === null){
+				$params['ContentType'] = 'binary/octet-stream';
+			}
+		}
+	}
+	
+	protected function makeRequest($model, &$operation, $params, $endpoint = null)
+	{
+		if($endpoint === null){
+			$endpoint = $this->endpoint;
+		}
+		$signatureInterface = strcasecmp($this-> signature, 'v4') === 0 ? 
+		new V4Signature($this->ak, $this->sk, $this->pathStyle, $endpoint, $this->region, $model['method'], $this->signature, $this->securityToken, $this->isCname) :
+		new DefaultSignature($this->ak, $this->sk, $this->pathStyle, $endpoint, $model['method'], $this->signature, $this->securityToken, $this->isCname);
+		$authResult = $signatureInterface -> doAuth($operation, $params, $model);
+		$httpMethod = $authResult['method'];
+		ObsLog::commonLog(DEBUG, 'perform '. strtolower($httpMethod) . ' request with url ' . $authResult['requestUrl']);
+		ObsLog::commonLog(DEBUG, 'cannonicalRequest:' . $authResult['cannonicalRequest']);
+		ObsLog::commonLog(DEBUG, 'request headers ' . var_export($authResult['headers'],true));
+		$authResult['headers']['User-Agent'] = self::default_user_agent();
+		if($model['method'] === 'putObject'){
+			$model['ObjectURL'] = ['value' => $authResult['requestUrl']];
+		}
+		return new Request($httpMethod, $authResult['requestUrl'], $authResult['headers'], $authResult['body']);
+	}
+	
+	
+	protected function doRequest($model, &$operation, $params, $endpoint = null)
+	{
+		$request = $this -> makeRequest($model, $operation, $params, $endpoint);
+		$this->sendRequest($model, $operation, $params, $request);
+	}
+	
+	protected function sendRequest($model, &$operation, $params, $request, $requestCount = 1)
+	{
+		$start = microtime(true);
+		$saveAsStream = false;
+		if(isset($operation['stream']) && $operation['stream']){
+			$saveAsStream = isset($params['SaveAsStream']) ? $params['SaveAsStream'] : false;
+			
+			if(isset($params['SaveAsFile'])){
+				if($saveAsStream){
+					$obsException = new ObsException('SaveAsStream cannot be used with SaveAsFile together');
+					$obsException-> setExceptionType('client');
+					throw $obsException;
+				}
+				$saveAsStream = true;
+			}
+			if(isset($params['FilePath'])){
+				if($saveAsStream){
+					$obsException = new ObsException('SaveAsStream cannot be used with FilePath together');
+					$obsException-> setExceptionType('client');
+					throw $obsException;
+				}
+				$saveAsStream = true;
+			}
+			
+			if(isset($params['SaveAsFile']) && isset($params['FilePath'])){
+				$obsException = new ObsException('SaveAsFile cannot be used with FilePath together');
+				$obsException-> setExceptionType('client');
+				throw $obsException;
+			}
+		}
+		
+		$promise = $this->httpClient->sendAsync($request, ['stream' => $saveAsStream])->then(
+		    function(Response $response) use ($model, $operation, $params, $request, $requestCount, $start){
+					
+					ObsLog::commonLog(INFO, 'http request cost ' . round(microtime(true) - $start, 3) * 1000 . ' ms');
+					$statusCode = $response -> getStatusCode();
+					$readable = isset($params['Body']) && ($params['Body'] instanceof StreamInterface || is_resource($params['Body']));
+					if($statusCode >= 300 && $statusCode <400 && $statusCode !== 304 && !$readable && $requestCount <= $this->maxRetryCount){
+						if($location = $response -> getHeaderLine('location')){
+							$url = parse_url($this->endpoint);
+							$newUrl = parse_url($location);
+							$scheme = (isset($newUrl['scheme']) ? $newUrl['scheme'] : $url['scheme']);
+							$defaultPort = strtolower($scheme) === 'https' ? '443' : '80';
+							$this->doRequest($model, $operation, $params, $scheme. '://' . $newUrl['host'] .
+									':' . (isset($newUrl['port']) ? $newUrl['port'] : $defaultPort));
+							return;
+						}
+					}
+					$this -> parseResponse($model, $request, $response, $operation);
+				},
+				function (RequestException $exception) use ($model, $operation, $params, $request, $requestCount, $start) {
+					
+					ObsLog::commonLog(INFO, 'http request cost ' . round(microtime(true) - $start, 3) * 1000 . ' ms');
+					$message = null;
+					if($exception instanceof ConnectException){
+						if($requestCount <= $this->maxRetryCount){
+							$this -> sendRequest($model, $operation, $params, $request, $requestCount + 1);
+							return;
+						}else{
+							$message = 'Exceeded retry limitation, max retry count:'. $this->maxRetryCount . ', error message:' . $exception -> getMessage();
+						}
+					}
+					$this -> parseException($model, $request, $exception, $message);
+				});
+		$promise -> wait();
+	}
+	
+	
+	protected function doRequestAsync($model, &$operation, $params, $callback, $startAsync, $originMethod, $endpoint = null){
+		$request = $this -> makeRequest($model, $operation, $params, $endpoint);
+		return $this->sendRequestAsync($model, $operation, $params, $callback, $startAsync, $originMethod, $request);
+	}
+	
+	protected function sendRequestAsync($model, &$operation, $params, $callback, $startAsync, $originMethod, $request, $requestCount = 1)
+	{
+		$start = microtime(true);
+		
+		$saveAsStream = false;
+		if(isset($operation['stream']) && $operation['stream']){
+			$saveAsStream = isset($params['SaveAsStream']) ? $params['SaveAsStream'] : false;
+			
+			if($saveAsStream){
+				if(isset($params['SaveAsFile'])){
+					$obsException = new ObsException('SaveAsStream cannot be used with SaveAsFile together');
+					$obsException-> setExceptionType('client');
+					throw $obsException;
+				}
+				if(isset($params['FilePath'])){
+					$obsException = new ObsException('SaveAsStream cannot be used with FilePath together');
+					$obsException-> setExceptionType('client');
+					throw $obsException;
+				}
+			}
+			
+			if(isset($params['SaveAsFile']) && isset($params['FilePath'])){
+				$obsException = new ObsException('SaveAsFile cannot be used with FilePath together');
+				$obsException-> setExceptionType('client');
+				throw $obsException;
+			}
+		}
+		return $this->httpClient->sendAsync($request, ['stream' => $saveAsStream])->then(
+				function(Response $response) use ($model, $operation, $params, $callback, $startAsync, $originMethod, $request, $start){
+					ObsLog::commonLog(INFO, 'http request cost ' . round(microtime(true) - $start, 3) * 1000 . ' ms');
+					$statusCode = $response -> getStatusCode();
+					$readable = isset($params['Body']) && ($params['Body'] instanceof StreamInterface || is_resource($params['Body']));
+					if($statusCode === 307 && !$readable){
+						if($location = $response -> getHeaderLine('location')){
+							$url = parse_url($this->endpoint);
+							$newUrl = parse_url($location);
+							$scheme = (isset($newUrl['scheme']) ? $newUrl['scheme'] : $url['scheme']);
+							$defaultPort = strtolower($scheme) === 'https' ? '443' : '80';
+							return $this->doRequestAsync($model, $operation, $params, $callback, $startAsync, $originMethod, $scheme. '://' . $newUrl['host'] .
+									':' . (isset($newUrl['port']) ? $newUrl['port'] : $defaultPort));
+						}
+					}
+					$this -> parseResponse($model, $request, $response, $operation);
+					ObsLog::commonLog(INFO, 'obsclient cost ' . round(microtime(true) - $startAsync, 3) * 1000 . ' ms to execute '. $originMethod);
+					unset($model['method']);
+					$callback(null, $model);
+				},
+				function (RequestException $exception) use ($model, $operation, $params, $callback, $startAsync, $originMethod, $request, $start, $requestCount){
+					ObsLog::commonLog(INFO, 'http request cost ' . round(microtime(true) - $start, 3) * 1000 . ' ms');
+					$message = null;
+					if($exception instanceof ConnectException){
+						if($requestCount <= $this->maxRetryCount){
+							return $this -> sendRequestAsync($model, $operation, $params, $callback, $startAsync, $originMethod, $request, $requestCount + 1);
+						}else{
+							$message = 'Exceeded retry limitation, max retry count:'. $this->maxRetryCount . ', error message:' . $exception -> getMessage();
+						}
+					}
+					$obsException = $this -> parseExceptionAsync($request, $exception, $message);
+					ObsLog::commonLog(INFO, 'obsclient cost ' . round(microtime(true) - $startAsync, 3) * 1000 . ' ms to execute '. $originMethod);
+					$callback($obsException, null);
+				}
+		);
+	}
+}

+ 471 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Signature/AbstractSignature.php

@@ -0,0 +1,471 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Signature;
+
+use Obs\Log\ObsLog;
+use Obs\Internal\Resource\Constants;
+use Obs\ObsException;
+use Obs\Internal\Common\SchemaFormatter;
+use GuzzleHttp\Psr7\Stream;
+use Obs\Internal\Common\Model;
+use Psr\Http\Message\StreamInterface;
+use Obs\Internal\Common\ObsTransform;
+use Obs\Internal\Common\V2Transform;
+
+abstract class AbstractSignature implements SignatureInterface
+{
+	
+	protected $ak;
+	
+	protected $sk;
+	
+	protected $pathStyle;
+	
+	protected $endpoint;
+	
+	protected $methodName;
+	
+	protected $securityToken;
+	
+	protected $signature;
+
+	protected $isCname;
+	
+	public static function urlencodeWithSafe($val, $safe='/'){
+		if(($len = strlen($val)) === 0){
+			return '';
+		}
+		$buffer = [];
+		for ($index=0;$index<$len;$index++){
+			$str = $val[$index];		
+			$buffer[] = !($pos = strpos($safe, $str)) && $pos !== 0 ? rawurlencode($str) : $str;
+		}
+		return implode('', $buffer);
+	}
+	
+	protected function __construct($ak, $sk, $pathStyle, $endpoint, $methodName, $signature, $securityToken=false, $isCname=false)
+	{
+		$this -> ak = $ak;
+		$this -> sk = $sk;
+		$this -> pathStyle = $pathStyle;
+		$this -> endpoint = $endpoint;
+		$this -> methodName = $methodName;
+		$this -> signature = $signature;
+		$this -> securityToken = $securityToken;
+		$this -> isCname = $isCname;
+	}
+	
+	protected function transXmlByType($key, &$value, &$subParams, $transHolder)
+	{
+		$xml = [];
+		$treatAsString = false;
+		if(isset($value['type'])){
+			$type = $value['type'];
+			if($type === 'array'){
+				$name = isset($value['sentAs']) ? $value['sentAs'] : $key;
+				$subXml = [];
+				foreach($subParams as $item){
+				    $temp = $this->transXmlByType($key, $value['items'], $item, $transHolder);
+					if($temp !== ''){
+						$subXml[] = $temp;
+					}
+				}
+				if(!empty($subXml)){
+				    if(!isset($value['data']['xmlFlattened'])){
+						$xml[] = '<' . $name . '>';
+						$xml[] = implode('', $subXml);
+						$xml[] = '</' . $name . '>';
+					}else{
+						$xml[] = implode('', $subXml);
+					}
+				}
+			}else if($type === 'object'){
+				$name = isset($value['sentAs']) ? $value['sentAs'] : (isset($value['name']) ? $value['name'] : $key);
+				$properties = $value['properties'];
+				$subXml = [];
+				$attr = [];
+				foreach ($properties as $pkey => $pvalue){
+					if(isset($pvalue['required']) && $pvalue['required'] && !isset($subParams[$pkey])){
+						$obsException= new ObsException('param:' .$pkey. ' is required');
+						$obsException-> setExceptionType('client');
+						throw $obsException;
+					}
+					if(isset($subParams[$pkey])){
+						if(isset($pvalue['data']) && isset($pvalue['data']['xmlAttribute']) && $pvalue['data']['xmlAttribute']){
+						    $attrValue = $this->xml_tansfer(trim(strval($subParams[$pkey])));
+						    $attr[$pvalue['sentAs']] = '"' . $attrValue . '"';
+							if(isset($pvalue['data']['xmlNamespace'])){
+								$ns = substr($pvalue['sentAs'], 0, strpos($pvalue['sentAs'], ':'));
+								$attr['xmlns:' . $ns] = '"' . $pvalue['data']['xmlNamespace'] . '"';
+							}
+						}else{
+						    $subXml[] = $this -> transXmlByType($pkey, $pvalue, $subParams[$pkey], $transHolder);
+						}
+					}
+				}
+				$val = implode('', $subXml);
+				if($val !== ''){
+					$_name = $name;
+					if(!empty($attr)){
+						foreach ($attr as $akey => $avalue){
+							$_name .= ' ' . $akey . '=' . $avalue;
+						}
+					}
+					if(!isset($value['data']['xmlFlattened'])){ 
+					    $xml[] = '<' . $_name . '>';
+					    $xml[] = $val;
+					    $xml[] = '</' . $name . '>';
+					} else {
+					    $xml[] = $val;
+					}
+				}
+			}else{
+				$treatAsString = true;
+			}
+		}else{
+			$treatAsString = true;
+			$type = null;
+		}
+		
+		if($treatAsString){
+			if($type === 'boolean'){
+				if(!is_bool($subParams) && strval($subParams) !== 'false' && strval($subParams) !== 'true'){
+					$obsException= new ObsException('param:' .$key. ' is not a boolean value');
+					$obsException-> setExceptionType('client');
+					throw $obsException;
+				}
+			}else if($type === 'numeric'){
+				if(!is_numeric($subParams)){
+					$obsException= new ObsException('param:' .$key. ' is not a numeric value');
+					$obsException-> setExceptionType('client');
+					throw $obsException;
+				}
+			}else if($type === 'float'){
+				if(!is_float($subParams)){
+					$obsException= new ObsException('param:' .$key. ' is not a float value');
+					$obsException-> setExceptionType('client');
+					throw $obsException;
+				}
+			}else if($type === 'int' || $type === 'integer'){
+				if(!is_int($subParams)){
+					$obsException= new ObsException('param:' .$key. ' is not a int value');
+					$obsException-> setExceptionType('client');
+					throw $obsException;
+				}
+			}
+			
+			$name = isset($value['sentAs']) ? $value['sentAs'] : $key;
+			if(is_bool($subParams)){
+				$val = 	$subParams ? 'true' : 'false';
+			}else{
+				$val = strval($subParams);
+			}
+			if(isset($value['format'])){
+				$val = SchemaFormatter::format($value['format'], $val);
+			}
+			if (isset($value['transform'])) {
+			    $val = $transHolder->transform($value['transform'], $val);
+			}			
+			if(isset($val) && $val !== ''){
+			    $val = $this->xml_tansfer($val);
+			    if(!isset($value['data']['xmlFlattened'])){
+			        $xml[] = '<' . $name . '>';
+			        $xml[] = $val;
+			        $xml[] = '</' . $name . '>';
+			    } else {
+			        $xml[] = $val;
+			    }			    
+			}else if(isset($value['canEmpty']) && $value['canEmpty']){
+			    $xml[] = '<' . $name . '>';
+			    $xml[] = $val;
+			    $xml[] = '</' . $name . '>';
+			}
+		}
+		$ret = implode('', $xml);
+		
+		if(isset($value['wrapper'])){
+		    $ret = '<'. $value['wrapper'] . '>' . $ret . '</'. $value['wrapper'] . '>';
+		}
+		
+		return $ret;
+	}
+	
+	private function xml_tansfer($tag) {
+	    $search = array('&', '<', '>', '\'', '"');
+	    $repalce = array('&amp;', '&lt;', '&gt;', '&apos;', '&quot;');
+	    $transferXml = str_replace($search, $repalce, $tag);
+	    return $transferXml;
+	}
+	
+	protected function prepareAuth(array &$requestConfig, array &$params, Model $model)
+	{
+	    $transHolder = strcasecmp($this-> signature, 'obs') === 0 ? ObsTransform::getInstance() : V2Transform::getInstance();
+		$method = $requestConfig['httpMethod'];
+		$requestUrl = $this->endpoint;
+		$headers = [];
+		$pathArgs = [];
+		$dnsParam = null;
+		$uriParam = null;
+		$body = [];
+		$xml = [];
+		
+		if(isset($requestConfig['specialParam'])){
+			$pathArgs[$requestConfig['specialParam']] = '';
+		}
+		
+		$result = ['body' => null];
+		$url = parse_url($requestUrl);
+		$host = $url['host'];
+		
+		$fileFlag = false;
+		
+		if(isset($requestConfig['requestParameters'])){
+			$paramsMetadata = $requestConfig['requestParameters'];
+			foreach ($paramsMetadata as $key => $value){
+				if(isset($value['required']) && $value['required'] && !isset($params[$key])){
+					$obsException= new ObsException('param:' .$key. ' is required');
+					$obsException-> setExceptionType('client');
+					throw $obsException;
+				}
+				if(isset($params[$key]) && isset($value['location'])){
+					$location = $value['location'];
+					$val = $params[$key];
+					$type = 'string';
+					if($val !== '' && isset($value['type'])){
+						$type = $value['type'];
+						if($type === 'boolean'){
+							if(!is_bool($val) && strval($val) !== 'false' && strval($val) !== 'true'){
+								$obsException= new ObsException('param:' .$key. ' is not a boolean value');
+								$obsException-> setExceptionType('client');
+								throw $obsException;
+							}
+						}else if($type === 'numeric'){
+							if(!is_numeric($val)){
+								$obsException= new ObsException('param:' .$key. ' is not a numeric value');
+								$obsException-> setExceptionType('client');
+								throw $obsException;
+							}
+						}else if($type === 'float'){
+							if(!is_float($val)){
+								$obsException= new ObsException('param:' .$key. ' is not a float value');
+								$obsException-> setExceptionType('client');
+								throw $obsException;
+							}
+						}else if($type === 'int' || $type === 'integer'){
+							if(!is_int($val)){
+								$obsException= new ObsException('param:' .$key. ' is not a int value');
+								$obsException-> setExceptionType('client');
+								throw $obsException;
+							}
+						}
+					}
+					
+					if($location === 'header'){
+						if($type === 'object'){
+							if(is_array($val)){
+								$sentAs = strtolower($value['sentAs']);
+								foreach ($val as $k => $v){
+									$k = self::urlencodeWithSafe(strtolower($k), ' ;/?:@&=+$,');
+									$name = strpos($k, $sentAs) === 0 ? $k : $sentAs . $k;
+									$headers[$name] = self::urlencodeWithSafe($v, ' ;/?:@&=+$,\'*');
+								}
+							}
+						}else if($type === 'array'){
+							if(is_array($val)){
+								$name = isset($value['sentAs']) ? $value['sentAs'] : (isset($value['items']['sentAs']) ? $value['items']['sentAs'] : $key);
+								$temp = [];
+								foreach ($val as $v){
+									if(($v = strval($v)) !== ''){
+									    $temp[] = self::urlencodeWithSafe($val, ' ;/?:@&=+$,\'*');
+									}
+								}
+
+								$headers[$name] = $temp;
+							}
+						}else if($type === 'password'){
+							if(($val = strval($val)) !== ''){
+								$name = isset($value['sentAs']) ? $value['sentAs'] : $key;
+								$pwdName = isset($value['pwdSentAs']) ? $value['pwdSentAs'] : $name . '-MD5';
+								$val1 = base64_encode($val);
+								$val2 = base64_encode(md5($val, true));
+								$headers[$name] = $val1;
+								$headers[$pwdName] = $val2;
+							}
+						}else{
+						    if (isset($value['transform'])) {
+						        $val = $transHolder->transform($value['transform'], strval($val));
+						    }
+							if(isset($val)){ 
+							    if(is_bool($val)){
+							        $val = $val ? 'true' : 'false';
+							    }else{
+							        $val = strval($val);
+							    }
+							    if($val !== ''){
+    								$name = isset($value['sentAs']) ? $value['sentAs'] : $key;
+    								if(isset($value['format'])){
+    									$val = SchemaFormatter::format($value['format'], $val);
+    								}
+    								$headers[$name] = self::urlencodeWithSafe($val, ' ;/?:@&=+$,\'*');
+							    }
+							}
+						}
+					}else if($location === 'uri' && $uriParam === null){
+						$uriParam = self::urlencodeWithSafe($val);
+					}else if($location === 'dns' && $dnsParam === null){
+						$dnsParam = $val;
+					}else if($location === 'query'){
+						$name = isset($value['sentAs']) ? $value['sentAs'] : $key;
+						if(strval($val) !== ''){
+						    if (strcasecmp ( $this->signature, 'v4' ) === 0) {
+						        $pathArgs[rawurlencode($name)] = rawurlencode(strval($val));
+						    } else {
+						        $pathArgs[self::urlencodeWithSafe($name)] = self::urlencodeWithSafe(strval($val));
+						    }
+						}
+					}else if($location === 'xml'){
+					    $val = $this->transXmlByType($key, $value, $val, $transHolder);
+						if($val !== ''){
+							$xml[] = $val;
+						}
+					}else if($location === 'body'){
+						
+						if(isset($result['body'])){
+							$obsException= new ObsException('duplicated body provided');
+							$obsException-> setExceptionType('client');
+							throw $obsException;
+						}
+						
+						if($type === 'file'){
+							if(!file_exists($val)){
+								$obsException= new ObsException('file[' .$val. '] does not exist');
+								$obsException-> setExceptionType('client');
+								throw $obsException;
+							}
+							$result['body'] = new Stream(fopen($val, 'r'));
+							$fileFlag = true;
+						}else if($type === 'stream'){
+							$result['body'] = $val;
+						} else if ($type === 'json') {
+						    //TODO
+                            $jsonData = json_encode($val);
+                            if (!$jsonData) {
+                                $obsException= new ObsException('input is invalid, since it is not json data');
+                                $obsException-> setExceptionType('client');
+                                throw $obsException;
+                            }
+                            $result['body'] = strval($jsonData);
+                        } else{
+							$result['body'] = strval($val);
+						}
+					}else if($location === 'response'){
+						$model[$key] = ['value' => $val, 'type' => $type];
+					}
+				}
+			}
+			
+			
+			if($dnsParam){
+				if($this -> pathStyle){
+					$requestUrl = $requestUrl . '/' .  $dnsParam;
+				}else{
+					$defaultPort = strtolower($url['scheme']) === 'https' ? '443' : '80';
+					$host = $this -> isCname ? $host : $dnsParam. '.' . $host;
+					$requestUrl = $url['scheme'] . '://' . $host . ':' . (isset($url['port']) ? $url['port'] : $defaultPort);
+				}
+			}
+			if($uriParam){
+				$requestUrl = $requestUrl . '/' . $uriParam;
+			}
+			
+			if(!empty($pathArgs)){
+				$requestUrl .= '?';
+				$_pathArgs = [];
+				foreach ($pathArgs as $key => $value){
+					$_pathArgs[] = $value === null || $value === '' ? $key : $key . '=' . $value;
+				}
+				$requestUrl .= implode('&', $_pathArgs);
+			}
+		}
+		
+		if($xml || (isset($requestConfig['data']['xmlAllowEmpty']) && $requestConfig['data']['xmlAllowEmpty'])){
+			$body[] = '<';
+			$xmlRoot = $requestConfig['data']['xmlRoot']['name'];
+			
+			$body[] = $xmlRoot;
+			$body[] = '>';
+			$body[] = implode('', $xml);
+			$body[] = '</';
+			$body[] = $xmlRoot;
+			$body[] = '>';
+			$headers['Content-Type'] = 'application/xml';
+			$result['body'] = implode('', $body);
+			
+			ObsLog::commonLog(DEBUG, 'request content ' . $result['body']);
+			
+			if(isset($requestConfig['data']['contentMd5']) && $requestConfig['data']['contentMd5']){
+				$headers['Content-MD5'] = base64_encode(md5($result['body'],true));
+			}
+		}
+		
+		if($fileFlag && ($result['body'] instanceof StreamInterface)){
+			if($this->methodName === 'uploadPart' && (isset($model['Offset']) || isset($model['PartSize']))){
+				$bodySize = $result['body'] ->getSize();
+				if(isset($model['Offset'])){
+					$offset = intval($model['Offset']['value']);
+					$offset = $offset >= 0 && $offset < $bodySize ? $offset : 0;
+				}else{
+					$offset = 0;
+				}
+				
+				if(isset($model['PartSize'])){
+					$partSize = intval($model['PartSize']['value']);
+					$partSize = $partSize > 0 && $partSize  <= ($bodySize - $offset) ? $partSize : $bodySize - $offset;
+				}else{
+					$partSize = $bodySize - $offset;
+				}
+				$result['body'] -> rewind();
+				$result['body'] -> seek($offset);
+				$headers['Content-Length'] = $partSize;
+			}else if(isset($headers['Content-Length'])){
+				$bodySize = $result['body'] -> getSize();
+				if(intval($headers['Content-Length']) > $bodySize){
+					$headers['Content-Length'] =  $bodySize;
+				}
+			}
+		}
+		
+		$constants = Constants::selectConstants($this -> signature);
+		
+		if($this->securityToken){
+		    $headers[$constants::SECURITY_TOKEN_HEAD] = $this->securityToken; 
+		}
+		
+		$headers['Host'] = $host;
+		
+		$result['host'] = $host;
+		$result['method'] = $method;
+		$result['headers'] = $headers;
+		$result['pathArgs'] = $pathArgs;
+		$result['dnsParam'] = $dnsParam;
+		$result['uriParam'] = $uriParam;
+		$result['requestUrl'] = $requestUrl;
+		
+		return $result;
+	}
+}

+ 138 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Signature/DefaultSignature.php

@@ -0,0 +1,138 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Signature;
+
+
+use Obs\Internal\Resource\Constants;
+use Obs\Internal\Common\Model;
+use Obs\Internal\Resource\V2Constants;
+
+class DefaultSignature extends AbstractSignature
+{
+	const INTEREST_HEADER_KEY_LIST = array('content-type', 'content-md5', 'date');
+	
+	
+	public function __construct($ak, $sk, $pathStyle, $endpoint, $methodName, $signature, $securityToken=false, $isCname=false)
+	{
+	    
+	    parent::__construct($ak, $sk, $pathStyle, $endpoint, $methodName, $signature, $securityToken, $isCname);
+	}
+	
+	public function doAuth(array &$requestConfig, array &$params, Model $model)
+	{   
+		$result = $this -> prepareAuth($requestConfig, $params, $model);
+		
+		$result['headers']['Date'] = gmdate('D, d M Y H:i:s \G\M\T');
+		$canonicalstring = $this-> makeCanonicalstring($result['method'], $result['headers'], $result['pathArgs'], $result['dnsParam'], $result['uriParam']);
+		
+		$result['cannonicalRequest'] = $canonicalstring;
+		
+		$signature = base64_encode(hash_hmac('sha1', $canonicalstring, $this->sk, true));
+		
+		$constants = Constants::selectConstants($this -> signature);
+		$signatureFlag = $constants::FLAG;
+		
+		$authorization = $signatureFlag . ' ' . $this->ak . ':' . $signature;
+		
+		$result['headers']['Authorization'] = $authorization;
+		
+		return $result;
+	}	
+	
+	public function makeCanonicalstring($method, $headers, $pathArgs, $bucketName, $objectKey, $expires = null)
+	{
+		$buffer = [];
+		$buffer[] = $method;
+		$buffer[] = "\n";	
+		$interestHeaders = [];
+		$constants = Constants::selectConstants($this -> signature);
+		
+		foreach ($headers as $key => $value){
+            $key = strtolower($key);
+			if(in_array($key, self::INTEREST_HEADER_KEY_LIST) || strpos($key, $constants::HEADER_PREFIX) === 0){
+				$interestHeaders[$key] = $value;
+			}
+		}
+		
+		if(array_key_exists($constants::ALTERNATIVE_DATE_HEADER, $interestHeaders)){
+			$interestHeaders['date'] = '';
+		} 
+		
+		if($expires !== null){
+			$interestHeaders['date'] = strval($expires);
+		}
+		
+		if(!array_key_exists('content-type', $interestHeaders)){
+			$interestHeaders['content-type'] = '';
+		}
+		
+		if(!array_key_exists('content-md5', $interestHeaders)){
+			$interestHeaders['content-md5'] = '';
+		}
+		
+		ksort($interestHeaders);
+		
+		foreach ($interestHeaders as $key => $value){
+		    if(strpos($key, $constants::HEADER_PREFIX) === 0){
+				$buffer[] = $key . ':' . $value;
+			}else{
+				$buffer[] = $value;
+			}
+			$buffer[] = "\n";
+		}
+		
+		$uri = '';
+
+		$bucketName = $this->isCname ? $headers['Host'] : $bucketName;
+
+		if($bucketName){
+			$uri .= '/';
+			$uri .= $bucketName;
+			if(!$this->pathStyle){
+				$uri .= '/';
+			}
+		}
+		
+		if($objectKey){
+			if(!($pos=strripos($uri, '/')) || strlen($uri)-1 !== $pos){
+				$uri .= '/';
+			}
+			$uri .= $objectKey;
+		}
+
+		$buffer[] = $uri === ''? '/' : $uri;
+
+
+		if(!empty($pathArgs)){
+			ksort($pathArgs);
+			$_pathArgs = [];
+			foreach ($pathArgs as $key => $value){
+			    if(in_array(strtolower($key), $constants::ALLOWED_RESOURCE_PARAMTER_NAMES) || strpos($key, $constants::HEADER_PREFIX) === 0){
+					$_pathArgs[] = $value === null || $value === '' ? $key : $key . '=' . urldecode($value);
+				}
+			}
+			if(!empty($_pathArgs)){
+				$buffer[] = '?';
+				$buffer[] = implode('&', $_pathArgs);
+			}
+		}
+
+		return implode('', $buffer);
+	}
+
+}

+ 25 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Signature/SignatureInterface.php

@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Signature;
+
+use Obs\Internal\Common\Model;
+
+interface SignatureInterface
+{
+	function doAuth(array &$requestConfig, array &$params, Model $model);
+}

+ 199 - 0
app/Libs/HuaweiObsSdk/Obs/Internal/Signature/V4Signature.php

@@ -0,0 +1,199 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Internal\Signature;
+
+use Obs\Internal\Common\Model;
+
+class V4Signature extends AbstractSignature
+{
+	const CONTENT_SHA256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
+	
+	protected $region;
+	
+	protected $utcTimeZone;
+	
+	public function __construct($ak, $sk, $pathStyle, $endpoint, $region, $methodName, $signature, $securityToken=false, $isCname=false)
+	{
+	    parent::__construct($ak, $sk, $pathStyle, $endpoint, $methodName, $signature, $securityToken, $isCname);
+		$this->region = $region;
+		$this->utcTimeZone = new \DateTimeZone ('UTC');
+	}
+	
+	public function doAuth(array &$requestConfig, array &$params, Model $model)
+	{
+		$result = $this -> prepareAuth($requestConfig, $params, $model);
+		
+		$result['headers']['x-amz-content-sha256'] = self::CONTENT_SHA256;
+		
+		$bucketName = $result['dnsParam'];
+		
+		$result['headers']['Host'] = $result['host'];
+		
+		$time = null;
+		if(array_key_exists('x-amz-date', $result['headers'])){
+			$time = $result['headers']['x-amz-date'];
+		}else if(array_key_exists('X-Amz-Date', $result['headers'])){
+			$time = $result['headers']['X-Amz-Date'];
+		}
+		$timestamp = $time ? date_create_from_format('Ymd\THis\Z', $time, $this->utcTimeZone) -> getTimestamp()
+				:time();
+		
+		$result['headers']['Date'] = gmdate('D, d M Y H:i:s \G\M\T', $timestamp);
+				
+		$longDate = gmdate('Ymd\THis\Z', $timestamp);
+		$shortDate = substr($longDate, 0, 8);
+		
+		$credential = $this-> getCredential($shortDate);
+		
+		$signedHeaders = $this->getSignedHeaders($result['headers']);
+		
+		$canonicalstring = $this-> makeCanonicalstring($result['method'], $result['headers'], $result['pathArgs'], $bucketName, $result['uriParam'], $signedHeaders);
+		
+		$result['cannonicalRequest'] = $canonicalstring;
+		
+		$signature = $this -> getSignature($canonicalstring, $longDate, $shortDate);
+		
+		$authorization = 'AWS4-HMAC-SHA256 ' . 'Credential=' . $credential. ',' . 'SignedHeaders=' . $signedHeaders . ',' . 'Signature=' . $signature;
+		
+		$result['headers']['Authorization'] = $authorization;
+		
+		return $result;
+	}
+	
+	public function getSignature($canonicalstring, $longDate, $shortDate)
+	{
+		$stringToSign = [];
+		$stringToSign[] = 'AWS4-HMAC-SHA256';
+		
+		$stringToSign[] = "\n";
+		
+		$stringToSign[] = $longDate;
+		
+		$stringToSign[] = "\n";
+		$stringToSign[] = $this -> getScope($shortDate);
+		$stringToSign[] = "\n";
+		
+		$stringToSign[] = hash('sha256', $canonicalstring);
+		
+		$dateKey = hash_hmac('sha256', $shortDate, 'AWS4' . $this -> sk, true);
+		$regionKey = hash_hmac('sha256', $this->region, $dateKey, true);
+		$serviceKey = hash_hmac('sha256', 's3', $regionKey, true);
+		$signingKey = hash_hmac('sha256', 'aws4_request', $serviceKey, true);
+		$signature = hash_hmac('sha256', implode('', $stringToSign), $signingKey);
+		return $signature;
+	}
+	
+	public function getCanonicalQueryString($pathArgs)
+	{
+		$queryStr = '';
+		
+		ksort($pathArgs);
+		$index = 0;
+		foreach ($pathArgs as $key => $value){
+			$queryStr .=  $key . '=' . $value;
+			if($index++ !== count($pathArgs) - 1){
+				$queryStr .= '&';
+			}
+		}
+		return $queryStr;
+	}
+	
+	public function getCanonicalHeaders($headers)
+	{
+		$_headers = [];
+		foreach ($headers as $key => $value) {
+			$_headers[strtolower($key)] = $value;
+		}
+		ksort($_headers);
+		
+		$canonicalHeaderStr = '';
+		
+		foreach ($_headers as $key => $value){
+			$value = is_array($value) ? implode(',', $value) : $value; 
+			$canonicalHeaderStr .= $key . ':' . $value;
+			$canonicalHeaderStr .= "\n";
+		}
+		return $canonicalHeaderStr;
+	}
+	
+	public function getCanonicalURI($bucketName, $objectKey)
+	{
+		$uri = '';
+		if($this -> pathStyle && $bucketName){
+			$uri .= '/' . $bucketName;
+		}
+		
+		if($objectKey){
+			$uri .= '/' . $objectKey;
+		}
+		
+		if($uri === ''){
+			$uri = '/';
+		}
+		return $uri;
+	}
+	
+	public function makeCanonicalstring($method, $headers, $pathArgs, $bucketName, $objectKey, $signedHeaders=null, $payload=null)
+	{
+		$buffer = [];
+		$buffer[] = $method;
+		$buffer[] = "\n";
+		$buffer[] = $this->getCanonicalURI($bucketName, $objectKey);
+		$buffer[] = "\n";
+		$buffer[] = $this->getCanonicalQueryString($pathArgs);
+		$buffer[] = "\n";
+		$buffer[] = $this->getCanonicalHeaders($headers);
+		$buffer[] = "\n";
+		$buffer[] = $signedHeaders ? $signedHeaders : $this->getSignedHeaders($headers);
+		$buffer[] = "\n";
+		$buffer[] = $payload ? strval($payload) : self::CONTENT_SHA256;
+		
+		return implode('', $buffer);
+	}
+	
+	public function getSignedHeaders($headers)
+	{
+		$_headers = [];
+		
+		foreach ($headers as $key => $value) {
+			$_headers[] = strtolower($key);
+		}
+		
+		sort($_headers);
+		
+		$signedHeaders = '';
+		
+		foreach ($_headers as $key => $value){
+			$signedHeaders .= $value;
+			if($key !== count($_headers) - 1){
+				$signedHeaders .= ';';
+			}
+		}
+		return $signedHeaders;
+	}
+	
+	public function getScope($shortDate)
+	{
+		return $shortDate . '/' . $this->region . '/s3/aws4_request';
+	}
+	
+	public function getCredential($shortDate)
+	{
+		return $this->ak . '/' . $this->getScope($shortDate);
+	}
+}

+ 28 - 0
app/Libs/HuaweiObsSdk/Obs/Log/ObsConfig.php

@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Log;
+
+class ObsConfig
+{
+	const LOG_FILE_CONFIG = [
+			'FilePath'=>'./logs',
+			'FileName'=>'eSDK-OBS-PHP.log',
+			'MaxFiles'=>10,
+			'Level'=>INFO
+	];
+}

+ 126 - 0
app/Libs/HuaweiObsSdk/Obs/Log/ObsLog.php

@@ -0,0 +1,126 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs\Log;
+
+use Monolog\Formatter\LineFormatter;
+use Monolog\Handler\RotatingFileHandler;
+use Monolog\Logger;
+
+class ObsLog extends Logger
+{
+	public static $log = null;
+	
+	protected $log_path = './';
+	protected $log_name = null;
+	protected $log_level = Logger::DEBUG;
+	protected $log_maxFiles = 0;
+	
+	private $formatter = null;
+	private $handler = null;
+	private $filepath = '';
+	
+	public static function initLog($logConfig= [])
+	{
+		$s3log = new ObsLog(''); 
+		$s3log->setConfig($logConfig);
+		$s3log->cheakDir();
+		$s3log->setFilePath();
+		$s3log->setFormat();
+		$s3log->setHande();
+	}
+	private function setFormat()
+	{
+		$output = '[%datetime%][%level_name%]'.'%message%' . "\n";
+		$this->formatter = new LineFormatter($output);
+		
+	}
+	private function setHande()
+	{
+		self::$log = new Logger('obs_logger');
+		$rotating = new RotatingFileHandler($this->filepath, $this->log_maxFiles, $this->log_level);
+		$rotating->setFormatter($this->formatter);
+		self::$log->pushHandler($rotating);
+	}
+	private function setConfig($logConfig= [])
+	{
+		$arr = empty($logConfig) ? ObsConfig::LOG_FILE_CONFIG : $logConfig;
+		$this->log_path = iconv('UTF-8', 'GBK',$arr['FilePath']);
+		$this->log_name = iconv('UTF-8', 'GBK',$arr['FileName']);
+		$this->log_maxFiles = is_numeric($arr['MaxFiles']) ? 0 : intval($arr['MaxFiles']);
+		$this->log_level = $arr['Level'];
+	}
+	private function cheakDir()
+	{
+		if (!is_dir($this->log_path)){
+			mkdir($this->log_path, 0755, true);
+		}
+	} 
+	private function setFilePath()
+	{
+		$this->filepath =  $this->log_path.'/'.$this->log_name;
+	}
+	private static function writeLog($level, $msg)
+	{
+		switch ($level) {
+			case DEBUG:
+				self::$log->debug($msg);
+				break;
+			case INFO:
+				self::$log->info($msg);
+				break;
+			case NOTICE:
+				self::$log->notice($msg);
+				break;
+			case WARNING:
+				self::$log->warning($msg);
+				break;
+			case ERROR:
+				self::$log->error($msg);
+				break;
+			case CRITICAL:
+				self::$log->critical($msg);
+				break;
+			case ALERT:
+				self::$log->alert($msg);
+				break;
+			case EMERGENCY:
+				self::$log->emergency($msg);
+				break;
+			default:
+				break;
+		}
+		
+	}
+	
+	public static function commonLog($level, $format, $args1 = null, $arg2 = null)
+	{
+		if(ObsLog::$log){
+		    if ($args1 === null && $arg2 === null) {
+		        $msg = urldecode($format);
+		    } else {
+		        $msg = sprintf($format, $args1, $arg2);
+		    }
+			$back = debug_backtrace();
+			$line = $back[0]['line'];
+			$funcname = $back[1]['function'];
+			$filename = basename($back[0]['file']);
+			$message = '['.$filename.':'.$line.']: '.$msg;
+			ObsLog::writeLog($level, $message);
+		}
+	}
+}

+ 415 - 0
app/Libs/HuaweiObsSdk/Obs/ObsClient.php

@@ -0,0 +1,415 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs;
+
+use Obs\Log\ObsLog;
+use Obs\Internal\Common\SdkCurlFactory;
+use Obs\Internal\Common\SdkStreamHandler;
+use Obs\Internal\Common\Model;
+use Monolog\Logger;
+use GuzzleHttp\Client;
+use GuzzleHttp\HandlerStack;
+use GuzzleHttp\Handler\CurlHandler;
+use GuzzleHttp\Handler\CurlMultiHandler;
+use GuzzleHttp\Handler\Proxy;
+use GuzzleHttp\Promise\Promise;
+use Obs\Internal\Resource\Constants;
+
+
+define('DEBUG', Logger::DEBUG);
+define('INFO', Logger::INFO);
+define('NOTICE', Logger::NOTICE);
+define('WARNING', Logger::WARNING);
+define('WARN', Logger::WARNING);
+define('ERROR', Logger::ERROR);
+define('CRITICAL', Logger::CRITICAL);
+define('ALERT', Logger::ALERT);
+define('EMERGENCY', Logger::EMERGENCY);
+
+/**
+ * @method Model createPostSignature(array $args=[]);
+ * @method Model createSignedUrl(array $args=[]);
+ * @method Model createBucket(array $args = []);
+ * @method Model listBuckets();
+ * @method Model deleteBucket(array $args = []);
+ * @method Model listObjects(array $args = []);
+ * @method Model listVersions(array $args = []);
+ * @method Model headBucket(array $args = []);
+ * @method Model getBucketMetadata(array $args = []);
+ * @method Model getBucketLocation(array $args = []);
+ * @method Model getBucketStorageInfo(array $args = []);
+ * @method Model setBucketQuota(array $args = []);
+ * @method Model getBucketQuota(array $args = []);
+ * @method Model setBucketStoragePolicy(array $args = []);
+ * @method Model getBucketStoragePolicy(array $args = []);
+ * @method Model setBucketAcl(array $args = []);
+ * @method Model getBucketAcl(array $args = []);
+ * @method Model setBucketLogging(array $args = []);
+ * @method Model getBucketLogging(array $args = []);
+ * @method Model setBucketPolicy(array $args = []);
+ * @method Model getBucketPolicy(array $args = []);
+ * @method Model deleteBucketPolicy(array $args = []);
+ * @method Model setBucketLifecycle(array $args = []);
+ * @method Model getBucketLifecycle(array $args = []);
+ * @method Model deleteBucketLifecycle(array $args = []);
+ * @method Model setBucketWebsite(array $args = []);
+ * @method Model getBucketWebsite(array $args = []);
+ * @method Model deleteBucketWebsite(array $args = []);
+ * @method Model setBucketVersioning(array $args = []);
+ * @method Model getBucketVersioning(array $args = []);
+ * @method Model setBucketCors(array $args = []);
+ * @method Model getBucketCors(array $args = []);
+ * @method Model deleteBucketCors(array $args = []);
+ * @method Model setBucketNotification(array $args = []);
+ * @method Model getBucketNotification(array $args = []);
+ * @method Model setBucketTagging(array $args = []);
+ * @method Model getBucketTagging(array $args = []);
+ * @method Model deleteBucketTagging(array $args = []);
+ * @method Model optionsBucket(array $args = []);
+ * @method Model getFetchPolicy(array $args = []);
+ * @method Model setFetchPolicy(array $args = []);
+ * @method Model deleteFetchPolicy(array $args = []);
+ * @method Model setFetchJob(array $args = []);
+ * @method Model getFetchJob(array $args = []);
+ *
+ * @method Model putObject(array $args = []);
+ * @method Model getObject(array $args = []);
+ * @method Model copyObject(array $args = []);
+ * @method Model deleteObject(array $args = []);
+ * @method Model deleteObjects(array $args = []);
+ * @method Model getObjectMetadata(array $args = []);
+ * @method Model setObjectAcl(array $args = []);
+ * @method Model getObjectAcl(array $args = []);
+ * @method Model initiateMultipartUpload(array $args = []);
+ * @method Model uploadPart(array $args = []);
+ * @method Model copyPart(array $args = []);
+ * @method Model listParts(array $args = []);
+ * @method Model completeMultipartUpload(array $args = []);
+ * @method Model abortMultipartUpload(array $args = []);
+ * @method Model listMultipartUploads(array $args = []);
+ * @method Model optionsObject(array $args = []);
+ * @method Model restoreObject(array $args = []);
+ *  
+ * @method Promise createBucketAsync(array $args = [], callable $callback);
+ * @method Promise listBucketsAsync(callable $callback);
+ * @method Promise deleteBucketAsync(array $args = [], callable $callback);
+ * @method Promise listObjectsAsync(array $args = [], callable $callback);
+ * @method Promise listVersionsAsync(array $args = [], callable $callback);
+ * @method Promise headBucketAsync(array $args = [], callable $callback);
+ * @method Promise getBucketMetadataAsync(array $args = [], callable $callback);
+ * @method Promise getBucketLocationAsync(array $args = [], callable $callback);
+ * @method Promise getBucketStorageInfoAsync(array $args = [], callable $callback);
+ * @method Promise setBucketQuotaAsync(array $args = [], callable $callback);
+ * @method Promise getBucketQuotaAsync(array $args = [], callable $callback);
+ * @method Promise setBucketStoragePolicyAsync(array $args = [], callable $callback);
+ * @method Promise getBucketStoragePolicyAsync(array $args = [], callable $callback);
+ * @method Promise setBucketAclAsync(array $args = [], callable $callback);
+ * @method Promise getBucketAclAsync(array $args = [], callable $callback);
+ * @method Promise setBucketLoggingAsync(array $args = [], callable $callback);
+ * @method Promise getBucketLoggingAsync(array $args = [], callable $callback);
+ * @method Promise setBucketPolicyAsync(array $args = [], callable $callback);
+ * @method Promise getBucketPolicyAsync(array $args = [], callable $callback);
+ * @method Promise deleteBucketPolicyAsync(array $args = [], callable $callback);
+ * @method Promise setBucketLifecycleAsync(array $args = [], callable $callback);
+ * @method Promise getBucketLifecycleAsync(array $args = [], callable $callback);
+ * @method Promise deleteBucketLifecycleAsync(array $args = [], callable $callback);
+ * @method Promise setBucketWebsiteAsync(array $args = [], callable $callback);
+ * @method Promise getBucketWebsiteAsync(array $args = [], callable $callback);
+ * @method Promise deleteBucketWebsiteAsync(array $args = [], callable $callback);
+ * @method Promise setBucketVersioningAsync(array $args = [], callable $callback);
+ * @method Promise getBucketVersioningAsync(array $args = [], callable $callback);
+ * @method Promise setBucketCorsAsync(array $args = [], callable $callback);
+ * @method Promise getBucketCorsAsync(array $args = [], callable $callback);
+ * @method Promise deleteBucketCorsAsync(array $args = [], callable $callback);
+ * @method Promise setBucketNotificationAsync(array $args = [], callable $callback);
+ * @method Promise getBucketNotificationAsync(array $args = [], callable $callback);
+ * @method Promise setBucketTaggingAsync(array $args = [], callable $callback);
+ * @method Promise getBucketTaggingAsync(array $args = [], callable $callback);
+ * @method Promise deleteBucketTaggingAsync(array $args = [], callable $callback);
+ * @method Promise optionsBucketAsync(array $args = [], callable $callback);
+ * 
+ * @method Promise putObjectAsync(array $args = [], callable $callback);
+ * @method Promise getObjectAsync(array $args = [], callable $callback);
+ * @method Promise copyObjectAsync(array $args = [], callable $callback);
+ * @method Promise deleteObjectAsync(array $args = [], callable $callback);
+ * @method Promise deleteObjectsAsync(array $args = [], callable $callback);
+ * @method Promise getObjectMetadataAsync(array $args = [], callable $callback);
+ * @method Promise setObjectAclAsync(array $args = [], callable $callback);
+ * @method Promise getObjectAclAsync(array $args = [], callable $callback);
+ * @method Promise initiateMultipartUploadAsync(array $args = [], callable $callback);
+ * @method Promise uploadPartAsync(array $args = [], callable $callback);
+ * @method Promise copyPartAsync(array $args = [], callable $callback);
+ * @method Promise listPartsAsync(array $args = [], callable $callback);
+ * @method Promise completeMultipartUploadAsync(array $args = [], callable $callback);
+ * @method Promise abortMultipartUploadAsync(array $args = [], callable $callback);
+ * @method Promise listMultipartUploadsAsync(array $args = [], callable $callback);
+ * @method Promise optionsObjectAsync(array $args = [], callable $callback);
+ * @method Promise restoreObjectAsync(array $args = [], callable $callback);
+ * @method Model getFetchPolicyAsync(array $args = [], callable $callback);
+ * @method Model setFetchPolicyAsync(array $args = [], callable $callback);
+ * @method Model deleteFetchPolicyAsync(array $args = [], callable $callback);
+ * @method Model setFetchJobAsync(array $args = [], callable $callback);
+ * @method Model getFetchJobAsync(array $args = [], callable $callback);
+ * 
+ */
+class ObsClient
+{
+	
+	const SDK_VERSION = '3.21.9';
+	
+	const AclPrivate = 'private';
+	const AclPublicRead = 'public-read';
+	const AclPublicReadWrite = 'public-read-write';
+	const AclPublicReadDelivered = 'public-read-delivered';
+	const AclPublicReadWriteDelivered = 'public-read-write-delivered';
+	
+	const AclAuthenticatedRead = 'authenticated-read';
+	const AclBucketOwnerRead = 'bucket-owner-read';
+	const AclBucketOwnerFullControl = 'bucket-owner-full-control';
+	const AclLogDeliveryWrite = 'log-delivery-write';
+	
+	const StorageClassStandard = 'STANDARD';
+	const StorageClassWarm = 'WARM';
+	const StorageClassCold = 'COLD';
+	
+	const PermissionRead = 'READ';
+	const PermissionWrite = 'WRITE';
+	const PermissionReadAcp = 'READ_ACP';
+	const PermissionWriteAcp = 'WRITE_ACP';
+	const PermissionFullControl = 'FULL_CONTROL';
+	
+	const AllUsers = 'Everyone';
+	
+	const GroupAllUsers = 'AllUsers';
+	const GroupAuthenticatedUsers = 'AuthenticatedUsers';
+	const GroupLogDelivery = 'LogDelivery';
+	
+	const RestoreTierExpedited = 'Expedited';
+	const RestoreTierStandard = 'Standard';
+	const RestoreTierBulk = 'Bulk';
+	
+	const GranteeGroup = 'Group';
+	const GranteeUser = 'CanonicalUser';
+	
+	const CopyMetadata = 'COPY';
+	const ReplaceMetadata = 'REPLACE';
+	
+	const SignatureV2 = 'v2';
+	const SignatureV4 = 'v4';
+	const SigantureObs = 'obs';
+	
+	const ObjectCreatedAll = 'ObjectCreated:*';
+	const ObjectCreatedPut = 'ObjectCreated:Put';
+	const ObjectCreatedPost = 'ObjectCreated:Post';
+	const ObjectCreatedCopy = 'ObjectCreated:Copy';
+	const ObjectCreatedCompleteMultipartUpload = 'ObjectCreated:CompleteMultipartUpload';
+	const ObjectRemovedAll = 'ObjectRemoved:*';
+	const ObjectRemovedDelete = 'ObjectRemoved:Delete';
+	const ObjectRemovedDeleteMarkerCreated = 'ObjectRemoved:DeleteMarkerCreated';
+	
+	use Internal\SendRequestTrait;
+	use Internal\GetResponseTrait;
+	
+	private $factorys;
+
+	public function __construct(array $config = []){
+		$this ->factorys = [];
+		
+		$this -> ak = strval($config['key']);
+		$this -> sk = strval($config['secret']);
+		
+		if(isset($config['security_token'])){
+		    $this -> securityToken = strval($config['security_token']);
+		}
+		
+		if(isset($config['endpoint'])){
+			$this -> endpoint = trim(strval($config['endpoint']));
+		}
+		
+		if($this -> endpoint === ''){
+			throw new \RuntimeException('endpoint is not set');
+		}
+		
+		while($this -> endpoint[strlen($this -> endpoint)-1] === '/'){
+			$this -> endpoint = substr($this -> endpoint, 0, strlen($this -> endpoint)-1);
+		}
+		
+		if(strpos($this-> endpoint, 'http') !== 0){
+			$this -> endpoint = 'https://' . $this -> endpoint;
+		}
+		
+		if(isset($config['signature'])){
+		    $this -> signature = strval($config['signature']);
+		}
+		
+		if(isset($config['path_style'])){
+			$this -> pathStyle = $config['path_style'];
+		}
+		
+		if(isset($config['region'])){
+			$this -> region = strval($config['region']);
+		}
+		
+		if(isset($config['ssl_verify'])){
+			$this -> sslVerify = $config['ssl_verify'];
+		}else if(isset($config['ssl.certificate_authority'])){
+			$this -> sslVerify = $config['ssl.certificate_authority'];
+		}
+		
+		if(isset($config['max_retry_count'])){
+			$this -> maxRetryCount = intval($config['max_retry_count']);
+		}
+		
+		if(isset($config['timeout'])){
+			$this -> timeout = intval($config['timeout']);
+		}
+		
+		if(isset($config['socket_timeout'])){
+			$this -> socketTimeout = intval($config['socket_timeout']);
+		}
+		
+		if(isset($config['connect_timeout'])){
+			$this -> connectTimeout = intval($config['connect_timeout']);
+		}
+		
+		if(isset($config['chunk_size'])){
+			$this -> chunkSize = intval($config['chunk_size']);
+		}
+		
+		if(isset($config['exception_response_mode'])){
+			$this -> exceptionResponseMode = $config['exception_response_mode'];
+		}
+
+		if (isset($config['is_cname'])) {
+		    $this -> isCname = $config['is_cname'];
+        }
+		
+		$host = parse_url($this -> endpoint)['host'];
+		if(filter_var($host, FILTER_VALIDATE_IP) !== false) {
+		    $this -> pathStyle = true;
+		}
+				
+		$handler = self::choose_handler($this);
+		
+		$this -> httpClient = new Client(
+				[
+						'timeout' => 0,
+						'read_timeout' => $this -> socketTimeout,
+						'connect_timeout' => $this -> connectTimeout,
+						'allow_redirects' => false,
+						'verify' => $this -> sslVerify,
+						'expect' => false,
+						'handler' => HandlerStack::create($handler),
+						'curl' => [
+								CURLOPT_BUFFERSIZE => $this -> chunkSize
+						]
+				]
+		);
+		
+	}
+	
+	public function __destruct(){
+		$this-> close();
+	}
+	
+	public function refresh($key, $secret, $security_token=false){
+	    $this -> ak = strval($key);
+	    $this -> sk = strval($secret);
+	    if($security_token){
+	        $this -> securityToken = strval($security_token);
+	    }
+	}
+	
+	/**
+	 * Get the default User-Agent string to use with Guzzle
+	 *
+	 * @return string
+	 */
+	private static function default_user_agent()
+	{
+		static $defaultAgent = '';
+		if (!$defaultAgent) {
+			$defaultAgent = 'obs-sdk-php/' . self::SDK_VERSION;
+		}
+		
+		return $defaultAgent;
+	}
+	
+	/**
+	 * Factory method to create a new Obs client using an array of configuration options.
+	 *
+	 * @param array $config Client configuration data
+	 *
+	 * @return ObsClient
+	 */
+	public static function factory(array $config = [])
+	{
+		return new ObsClient($config);
+	}
+	
+	public function close(){
+		if($this->factorys){
+			foreach ($this->factorys as $factory){
+				$factory->close();
+			}
+		}
+	}
+	
+	public function initLog(array $logConfig= [])
+	{
+		ObsLog::initLog($logConfig);
+		
+		$msg = [];
+		$msg[] = '[OBS SDK Version=' . self::SDK_VERSION;
+		$msg[] = 'Endpoint=' . $this->endpoint;
+		$msg[] = 'Access Mode=' . ($this->pathStyle ? 'Path' : 'Virtual Hosting').']';
+		
+		ObsLog::commonLog(WARNING, implode("];[", $msg));
+	}
+	
+	private static function choose_handler($obsclient)
+	{
+		$handler = null;
+		if (function_exists('curl_multi_exec') && function_exists('curl_exec')) {
+			$f1 = new SdkCurlFactory(50);
+			$f2 = new SdkCurlFactory(3);
+			$obsclient->factorys[] = $f1;
+			$obsclient->factorys[] = $f2;
+			$handler = Proxy::wrapSync(new CurlMultiHandler(['handle_factory' => $f1]), new CurlHandler(['handle_factory' => $f2]));
+		} elseif (function_exists('curl_exec')) {
+			$f = new SdkCurlFactory(3);
+			$obsclient->factorys[] = $f;
+			$handler = new CurlHandler(['handle_factory' => $f]);
+		} elseif (function_exists('curl_multi_exec')) {
+			$f = new SdkCurlFactory(50);
+			$obsclient->factorys[] = $f;
+			$handler = new CurlMultiHandler(['handle_factory' => $f1]);
+		}
+		
+		if (ini_get('allow_url_fopen')) {
+			$handler = $handler
+			? Proxy::wrapStreaming($handler, new SdkStreamHandler())
+			: new SdkStreamHandler();
+		} elseif (!$handler) {
+			throw new \RuntimeException('GuzzleHttp requires cURL, the '
+					. 'allow_url_fopen ini setting, or a custom HTTP handler.');
+		}
+		
+		return $handler;
+	}
+}

+ 140 - 0
app/Libs/HuaweiObsSdk/Obs/ObsException.php

@@ -0,0 +1,140 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+namespace Obs;
+
+use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\Psr7\Response;
+use Obs\Log\ObsLog;
+
+class ObsException extends \RuntimeException
+{
+	const CLIENT = 'client';
+	
+	const SERVER = 'server';
+	
+    private $response;
+
+    private $request;
+
+    private $requestId;
+
+    private $exceptionType;
+        
+    private $exceptionCode;
+    
+    private $exceptionMessage;
+    
+    private $hostId;
+	
+    public function __construct ($message = null, $code = null, $previous = null) 
+    {
+    	parent::__construct($message, $code, $previous);
+    }
+    
+    public function setExceptionCode($exceptionCode)
+    {
+        $this->exceptionCode = $exceptionCode;
+    }
+
+    public function getExceptionCode()
+    {
+        return $this->exceptionCode;
+    }
+    
+    public function setExceptionMessage($exceptionMessage)
+    {
+        $this->exceptionMessage = $exceptionMessage;
+    }
+    
+    public function getExceptionMessage()
+    {
+    	return $this->exceptionMessage ? $this->exceptionMessage : $this->message;
+    }
+
+    public function setExceptionType($exceptionType)
+    {
+        $this->exceptionType = $exceptionType;
+    }
+
+    public function getExceptionType()
+    {
+        return $this->exceptionType;
+    }
+
+    public function setRequestId($requestId)
+    {
+        $this->requestId = $requestId;
+    }
+
+    public function getRequestId()
+    {
+        return $this->requestId;
+    }
+
+    public function setResponse(Response $response)
+    {
+        $this->response = $response;
+    }
+
+    public function getResponse()
+    {
+        return $this->response;
+    }
+
+    public function setRequest(Request $request)
+    {
+        $this->request = $request;
+    }
+
+    public function getRequest()
+    {
+        return $this->request;
+    }
+
+    public function getStatusCode()
+    {
+        return $this->response ? $this->response->getStatusCode() : -1;
+    }
+    
+    public function setHostId($hostId){
+    	$this->hostId = $hostId;
+    }
+    
+    public function getHostId(){
+    	return $this->hostId;
+    }
+
+    public function __toString()
+    {
+        $message = get_class($this) . ': '
+            . 'OBS Error Code: ' . $this->getExceptionCode() . ', '
+            . 'Status Code: ' . $this->getStatusCode() . ', '
+            . 'OBS Error Type: ' . $this->getExceptionType() . ', '
+            . 'OBS Error Message: ' . ($this->getExceptionMessage() ? $this->getExceptionMessage():$this->getMessage());
+
+        // Add the User-Agent if available
+        if ($this->request) {
+            $message .= ', ' . 'User-Agent: ' . $this->request->getHeaderLine('User-Agent');
+        }
+        $message .= "\n";
+        
+        ObsLog::commonLog(INFO, "http request:status:%d, %s",$this->getStatusCode(),"code:".$this->getExceptionCode().", message:".$this->getMessage());
+        return $message;
+    }
+    
+}

+ 32 - 0
app/Libs/HuaweiObsSdk/README.md

@@ -0,0 +1,32 @@
+Version 3.22.6
+
+新特性:
+
+资料&demo:
+
+修复问题:
+1. 修复三方依赖冲突的问题;
+
+----
+
+Version 3.19.9
+
+新特性:
+
+资料&demo:
+
+修复问题:
+1. 修复OBS请求时,Host偶尔被异常替换的问题;
+2. 修复特殊场景下,日志模块无法正常工作的问题;
+3. 修复header中的正常特殊字符被url编码的问题;
+
+-------------------------------------------------------------------------------------------------
+
+Version 3.1.3
+新特性:
+
+资料&demo:
+
+修复问题:
+1. 修复连接OBS服务超时时,解析request-id报错导致异常信息被截断的问题;
+

+ 19 - 0
app/Libs/HuaweiObsSdk/composer.json

@@ -0,0 +1,19 @@
+{
+	"name" : "obs/esdk-obs-php",
+	"description" : "OBS PHP SDK",
+	"license":"Apache-2.0",
+	"version":"3.22.6",
+	"require" : {
+		"php" : ">=5.6.0",
+		"guzzlehttp/guzzle" : "^6.3.0 || ^7.0",
+		"guzzlehttp/psr7" : "^1.4.2 || ^2.0",
+		"monolog/monolog" : "^1.23.0 || ^2.0"
+	},
+	
+	"keywords" :["obs", "php"],
+	"autoload": {
+		"psr-4": {
+			"Obs\\": "Obs/"
+		}
+    }
+}

+ 503 - 0
app/Libs/HuaweiObsSdk/examples/BucketOperationsSample.php

@@ -0,0 +1,503 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to do bucket-related operations
+ * (such as do bucket ACL/CORS/Lifecycle/Logging/Website/Location/Tagging/OPTIONS) 
+ * on OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+use function GuzzleHttp\json_encode;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [ 
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+
+try {
+	
+	/*
+	 * Put bucket operation
+	 */
+	createBucket ();
+	
+	/*
+	 * Get bucket location operation
+	 */
+	getBucketLocation ();
+	
+	/*
+	 * Get bucket storageInfo operation
+	 */
+	getBucketStorageInfo ();
+	
+	/*
+	 * Put/Get bucket quota operations
+	 */
+	doBucketQuotaOperation ();
+	
+	/*
+	 * Put/Get bucket versioning operations
+	 */
+	doBucketVersioningOperation ();
+	
+	/*
+	 * Put/Get bucket acl operations
+	 */
+	$ownerId = doBucketAclOperation ();
+	
+	/*
+	 * Put/Get/Delete bucket cors operations
+	 */
+	doBucketCorsOperation ();
+	
+	/*
+	 * Options bucket operation
+	 */
+	optionsBucket ();
+
+	/*
+	 * Get bucket metadata operation
+	 */
+	getBucketMetadata ();
+	
+	/*
+	 * Put/Get/Delete bucket lifecycle operations
+	 */
+	doBucketLifecycleOperation ();
+	
+	/*
+	 * Put/Get/Delete bucket logging operations
+	 */
+	doBucketLoggingOperation ($ownerId);
+	
+	/*
+	 * Put/Get/Delete bucket website operations
+	 */
+	doBucketWebsiteOperation ();
+	
+	/*
+	 * Put/Get/Delete bucket tagging operations
+	 */
+	doBucketTaggingOperation ();
+	
+	/*
+	 * Delete bucket operation
+	 */
+	deleteBucket ();
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}
+
+
+function createBucket() 
+{
+	global $obsClient;
+	global $bucketName;
+	
+	$resp = $obsClient->createBucket ([
+		'Bucket' => $bucketName,
+	]);
+	printf("HttpStatusCode:%s\n\n", $resp ['HttpStatusCode']);
+	printf("Create bucket: %s successfully!\n\n", $bucketName);
+}
+
+function getBucketLocation() 
+{
+	global $obsClient;
+	global $bucketName;
+	
+	$promise = $obsClient -> getBucketLocationAsync(['Bucket' => $bucketName], function($exception, $resp){
+		printf("Getting bucket location %s\n\n", $resp ['Location']);
+	});
+	$promise -> wait();
+}
+
+function getBucketStorageInfo() 
+{
+	global $obsClient;
+	global $bucketName;
+	$promise = $obsClient -> getBucketStorageInfoAsync(['Bucket' => $bucketName], function($exception, $resp){
+		printf("Getting bucket storageInfo Size:%d,ObjectNumber:%d\n\n", $resp ['Size'], $resp ['ObjectNumber']);
+	});
+	$promise -> wait();
+}
+
+function doBucketQuotaOperation()
+{
+	global $obsClient;
+	global $bucketName;
+	$obsClient->setBucketQuota ([
+			'Bucket' => $bucketName,
+			'StorageQuota' => 1024 * 1024 * 1024//Set bucket quota to 1GB
+	]);
+	
+	$resp = $obsClient->getBucketQuota ([
+			'Bucket' => $bucketName
+	]);
+	printf ("Getting bucket quota:%s\n\n", $resp ['StorageQuota'] );
+}
+
+function doBucketVersioningOperation() 
+{
+	global $obsClient;
+	global $bucketName;
+	
+	$resp = $obsClient->getBucketVersioningConfiguration ( [
+			'Bucket' => $bucketName
+	]);
+	printf ( "Getting bucket versioning config:%s\n\n", $resp ['Status']);
+	//Enable bucket versioning
+	$obsClient->setBucketVersioningConfiguration ([
+			'Bucket' => $bucketName,
+			'Status' => 'Enabled'
+	]);
+	$resp = $obsClient->getBucketVersioningConfiguration ( [
+			'Bucket' => $bucketName
+	]);
+	printf ( "Current bucket versioning config:%s\n\n", $resp ['Status']);
+	
+	//Suspend bucket versioning
+	$obsClient->setBucketVersioningConfiguration ([
+			'Bucket' => $bucketName,
+			'Status' => 'Suspended'
+	]);
+	$resp = $obsClient->getBucketVersioningConfiguration ( [
+			'Bucket' => $bucketName
+	]);
+	printf ( "Current bucket versioning config:%s\n\n", $resp ['Status']);
+}
+
+function doBucketAclOperation() 
+{
+	global $obsClient;
+	global $bucketName;
+	printf ("Setting bucket ACL to ". ObsClient::AclPublicRead. "\n\n");
+	$obsClient->setBucketAcl ([
+			'Bucket' => $bucketName,
+			'ACL' => ObsClient::AclPublicRead,
+	]);
+	
+	$resp = $obsClient->getBucketAcl ([
+			'Bucket' => $bucketName
+	]);
+	printf ("Getting bucket ACL:%s\n\n", json_encode($resp -> toArray()));
+	
+	printf ("Setting bucket ACL to ". ObsClient::AclPrivate. "\n\n");
+	
+	$obsClient->setBucketAcl ([
+			'Bucket' => $bucketName,
+			'ACL' => ObsClient::AclPrivate,
+	]);
+	$resp = $obsClient->getBucketAcl ([
+			'Bucket' => $bucketName
+	]);
+	printf ("Getting bucket ACL:%s\n\n", json_encode($resp -> toArray()));
+	return $resp ['Owner'] ['ID'];
+}
+
+function doBucketCorsOperation() 
+{
+	global $obsClient;
+	global $bucketName;
+	printf ("Setting bucket CORS\n\n");
+	$obsClient->setBucketCors ( [
+			'Bucket' => $bucketName,
+			'CorsRule' => [
+					[
+							'AllowedMethod' => ['HEAD', 'GET', 'PUT'],
+							'AllowedOrigin' => ['http://www.a.com', 'http://www.b.com'],
+							'AllowedHeader'=> ['Authorization'],
+							'ExposeHeaders' => ['x-obs-test1', 'x-obs-test2'],
+							'MaxAgeSeconds' => 100
+					]
+			]
+	] );
+	printf ("Getting bucket CORS:%s\n\n", json_encode($obsClient-> getBucketCors(['Bucket' => $bucketName])-> toArray()));
+	
+}
+
+function optionsBucket() 
+{
+	global $obsClient;
+	global $bucketName;
+	
+	$resp = $obsClient->optionsBucket([
+			'Bucket'=>$bucketName,
+			'Origin'=>'http://www.a.com',
+			'AccessControlRequestMethods' => ['PUT'],
+			'AccessControlRequestHeaders'=> ['Authorization']
+	]);
+	printf ("Options bucket: %s\n\n", json_encode($resp -> toArray()));
+	
+}
+
+function getBucketMetadata() 
+{
+	global $obsClient;
+	global $bucketName;
+	printf ("Getting bucket metadata\n\n");
+	
+	$resp = $obsClient->getBucketMetadata ( [
+			"Bucket" => $bucketName,
+			"Origin" => "http://www.a.com",
+			"RequestHeader" => "Authorization"
+	] );
+	printf ( "\tHttpStatusCode:%s\n", $resp ['HttpStatusCode'] );
+	printf ( "\tStorageClass:%s\n", $resp ["StorageClass"] );
+	printf ( "\tAllowOrigin:%s\n", $resp ["AllowOrigin"] );
+	printf ( "\tMaxAgeSeconds:%s\n", $resp ["MaxAgeSeconds"] );
+	printf ( "\tExposeHeader:%s\n", $resp ["ExposeHeader"] );
+	printf ( "\tAllowHeader:%s\n", $resp ["AllowHeader"] );
+	printf ( "\tAllowMethod:%s\n", $resp ["AllowMethod"] );
+	
+	printf ("Deleting bucket CORS\n\n");
+	$obsClient -> deleteBucketCors(['Bucket' => $bucketName]);
+}
+
+function doBucketLifecycleOperation() 
+{
+	global $obsClient;
+	global $bucketName;
+	
+	$ruleId0 = "delete obsoleted files";
+	$matchPrefix0 = "obsoleted/";
+	$ruleId1 = "delete temporary files";
+	$matchPrefix1 = "temporary/";
+	$ruleId2 = "delete temp files";
+	$matchPrefix2 = "temp/";
+	
+	printf ("Setting bucket lifecycle\n\n");
+	
+	$obsClient->setBucketLifecycleConfiguration ( [
+			'Bucket' => $bucketName,
+			'Rules' => [
+					[
+							'ID' => $ruleId0,
+							'Prefix' => $matchPrefix0,
+							'Status' => 'Enabled',
+							'Expiration'=> ['Days'=>5]
+					],
+					[
+							'ID' => $ruleId1,
+							'Prefix' => $matchPrefix1,
+							'Status' => 'Enabled',
+							'Expiration' => ['Date' => '2017-12-31T00:00:00Z']
+					],
+					[
+							'ID' => $ruleId2,
+							'Prefix' => $matchPrefix2,
+							'Status' => 'Enabled',
+							'NoncurrentVersionExpiration' => ['NoncurrentDays' => 10]
+					]
+			]
+	]);
+	
+	printf ("Getting bucket lifecycle\n\n");
+	
+	$resp = $obsClient->getBucketLifecycleConfiguration ([
+			'Bucket' => $bucketName
+	]);
+	
+	$i = 0;
+	foreach ( $resp ['Rules'] as $rule ) {
+		printf ( "\tRules[$i][Expiration][Date]:%s,Rules[$i][Expiration][Days]:%d\n", $rule ['Expiration'] ['Date'], $rule ['Expiration'] ['Days'] );
+		printf ( "\yRules[$i][NoncurrentVersionExpiration][NoncurrentDays]:%s\n", $rule ['NoncurrentVersionExpiration'] ['NoncurrentDays'] );
+		printf ( "\tRules[$i][ID]:%s,Rules[$i][Prefix]:%s,Rules[$i][Status]:%s\n", $rule ['ID'], $rule ['Prefix'], $rule ['Status'] );
+		$i ++;
+	}
+	
+	printf ("Deleting bucket lifecycle\n\n");
+	$obsClient->deleteBucketLifecycleConfiguration (['Bucket' => $bucketName]);
+}
+
+function doBucketLoggingOperation($ownerId) 
+{
+	global $obsClient;
+	global $bucketName;
+	
+	printf ("Setting bucket ACL, give the log-delivery group " . ObsClient::PermissionWrite ." and " .ObsClient::PermissionReadAcp ." permissions\n\n");
+	
+	$obsClient->setBucketAcl ([
+			'Bucket' => $bucketName,
+			'Owner' => [
+					'ID' => $ownerId
+			],
+			'Grants' => [
+					[
+							'Grantee' => [
+							        'URI' => ObsClient::GroupLogDelivery,
+									'Type' => 'Group'
+							],
+					       'Permission' => ObsClient::PermissionWrite
+					],
+					[
+							'Grantee' => [
+							        'URI' => ObsClient::GroupLogDelivery,
+									'Type' => 'Group'
+							],
+					       'Permission' => ObsClient::PermissionReadAcp
+					],
+			]
+	]);
+	
+	printf ("Setting bucket logging\n\n");
+	
+	$targetBucket = $bucketName;
+	$targetPrefix = 'log-';
+	
+	$obsClient->setBucketLoggingConfiguration ( [
+			'Bucket' => $bucketName,
+			'LoggingEnabled' => [
+					'TargetBucket' => $targetBucket,
+					'TargetPrefix' => $targetPrefix,
+					'TargetGrants' => [
+							[
+									'Grantee' => [
+									        'URI' => ObsClient::GroupAuthenticatedUsers,
+											'Type' => 'Group'
+									],
+									'Permission' => ObsClient::PermissionRead
+							]
+					]
+			]
+	]);
+	
+	printf ("Getting bucket logging\n");
+	
+	$resp = $obsClient->getBucketLoggingConfiguration ([
+			'Bucket' => $bucketName
+	]);
+	
+	printf ("\tTarget bucket=%s, target prefix=%s\n", $resp ['LoggingEnabled'] ['TargetBucket'], $resp ['LoggingEnabled'] ['TargetPrefix'] );
+	printf("\tTargetGrants=%s\n\n", json_encode($resp ['LoggingEnabled'] ['TargetGrants']));
+	
+	printf ("Deletting bucket logging\n");
+	
+	$obsClient->setBucketLoggingConfiguration ( [
+			'Bucket' => $bucketName
+	]);
+}
+
+function doBucketWebsiteOperation() 
+{
+	global $obsClient;
+	global $bucketName;
+	
+	printf ("Setting bucket website\n\n");
+	
+	$obsClient->setBucketWebsiteConfiguration ([
+			'Bucket' => $bucketName,
+			'IndexDocument' => [
+					'Suffix' => 'index.html'
+			],
+			'ErrorDocument' => [
+					'Key' => 'error.html'
+			]
+	]);
+	printf ("Getting bucket website\n");
+	
+	$resp = $obsClient->GetBucketWebsiteConfiguration ( [
+			'Bucket' => $bucketName
+	]);
+	
+	printf ("\tIndex document=%s, error document=%s\n\n", $resp ['IndexDocument'] ['Suffix'], $resp ['ErrorDocument'] ['Key']);
+	printf ("Deletting bucket website\n");
+	
+	$obsClient->deleteBucketWebsiteConfiguration ([
+			'Bucket' => $bucketName
+	]);
+}
+
+function doBucketTaggingOperation() 
+{
+	global $obsClient;
+	global $bucketName;
+	printf ("Setting bucket tagging\n\n");
+	$obsClient -> setBucketTagging([
+			'Bucket' => $bucketName,
+			'TagSet' => [
+					[
+							'Key' => 'testKey1',
+							'Value' => 'testValue1'
+					],
+					[
+							'Key' => 'testKey2',
+							'Value' => 'testValue2'
+					]
+			]
+	]);
+	printf ("Getting bucket tagging\n");
+	
+	$resp = $obsClient -> getBucketTagging(['Bucket' => $bucketName]);
+	
+	printf ("\t%s\n\n", json_encode($resp->toArray()));
+	
+	printf ("Deletting bucket tagging\n\n");
+	
+	$obsClient -> deleteBucketTagging(['Bucket' => $bucketName]);
+}
+
+function deleteBucket() 
+{
+	
+	global $obsClient;
+	global $bucketName;
+	
+	$resp = $obsClient->deleteBucket ([
+			'Bucket' => $bucketName
+	] );
+	printf("Deleting bucket %s successfully!\n\n", $bucketName);
+	printf("HttpStatusCode:%s\n\n", $resp ['HttpStatusCode']);
+}
+
+

+ 221 - 0
app/Libs/HuaweiObsSdk/examples/ConcurrentCopyPartSample.php

@@ -0,0 +1,221 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to multipart upload an object concurrently by copy mode
+ * to OBS using the OBS SDK for PHP.
+ */
+
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$sourceBucketName = $bucketName;
+
+$sourceObjectKey = 'my-obs-object-key-demo';
+
+
+$objectKey = $sourceObjectKey . '-back';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	/*
+	 * Create bucket
+	 */
+	printf("Create a new bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	
+	$sampleFilePath = '/temp/test.txt'; //sample large file path
+	//  you can prepare a large file in you filesystem first
+	createSampleFile($sampleFilePath);
+
+	/*
+	 * Upload an object to your source bucket
+	 */
+	$obsClient -> putObject(['Bucket' => $sourceBucketName, 'Key' => $sourceObjectKey, 'SourceFile' => $sampleFilePath]);
+	
+	/*
+	 * Claim a upload id firstly
+	 */
+	$resp = $obsClient -> initiateMultipartUpload(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	$uploadId = $resp['UploadId'];
+	printf("Claiming a new upload id %s\n\n", $uploadId);
+	
+	
+	$partSize = 5 * 1024 * 1024;
+	$resp = $obsClient -> getObjectMetadata(['Bucket' => $sourceBucketName, 'Key' => $sourceObjectKey]);
+	$objectSize = $resp['ContentLength'];
+	
+	$partCount = $objectSize % $partSize === 0 ? intval($objectSize / $partSize) : intval($objectSize / $partSize) + 1;
+	
+	if($partCount > 10000){
+		throw new \RuntimeException('Total parts count should not exceed 10000');
+	}
+	printf("Total parts count %d\n\n", $partCount);
+	
+	/*
+	 * Upload multiparts by copy mode
+	 */
+	$promise = null;
+	$parts = [];
+	printf("Begin to upload multiparts to OBS by copy mode\n\n");
+	for($i = 0; $i < $partCount; $i++){
+		$rangeStart = $i * $partSize;
+		$rangeEnd = ($i + 1 === $partCount) ? $objectSize - 1 : $rangeStart + $partSize - 1;
+		$partNumber = $i + 1;
+		$p = $obsClient -> copyPartAsync([
+				'Bucket' => $bucketName,
+				'Key' => $objectKey,
+				'UploadId' => $uploadId,
+				'PartNumber' => $partNumber,
+				'CopySource'=>sprintf('%s/%s', $sourceBucketName, $sourceObjectKey),
+				'CopySourceRange' => sprintf('bytes=%d-%d', $rangeStart, $rangeEnd)
+		], function($exception, $resp) use (&$parts, $partNumber){
+			$parts[] = ['PartNumber' => $partNumber, 'ETag' => $resp['ETag']];
+			printf ( "Part#" . strval ( $partNumber ) . " done\n\n" );
+		});
+		
+		if($promise === null){
+			$promise = $p;
+		}
+	}
+	
+	
+	/*
+	 * Waiting for all parts finished
+	 */
+	$promise->wait();
+	
+	usort($parts, function($a, $b){
+		if($a['PartNumber'] === $b['PartNumber']){
+			return 0;
+		}
+		return $a['PartNumber'] > $b['PartNumber'] ? 1 : -1;
+	});
+	
+	/*
+	 * Verify whether all parts are finished
+	 */
+	if(count($parts) !== $partCount){
+		throw new \RuntimeException('Upload multiparts fail due to some parts are not finished yet');
+	}
+	
+	
+	printf("Succeed to complete multiparts into an object named %s\n\n", $objectKey);
+	
+	/*
+	 * View all parts uploaded recently
+	 */
+	printf("Listing all parts......\n");
+	$resp = $obsClient -> listParts(['Bucket' => $bucketName, 'Key' => $objectKey, 'UploadId' => $uploadId]);
+	foreach ($resp['Parts'] as $part)
+	{
+		printf("\tPart#%d, ETag=%s\n", $part['PartNumber'], $part['ETag']);
+	}
+	printf("\n");
+	
+	/*
+	 * Complete to upload multiparts
+	 */
+	$resp = $obsClient->completeMultipartUpload([
+			'Bucket' => $bucketName,
+			'Key' => $objectKey,
+			'UploadId' => $uploadId,
+			'Parts'=> $parts
+	]);
+	
+	if(file_exists($sampleFilePath)){
+		unlink($sampleFilePath);
+	}
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}
+
+
+function createSampleFile($filePath)
+{
+	if(file_exists($filePath)){
+		return;
+	}
+	$filePath = iconv('UTF-8', 'GBK', $filePath);
+	if(is_string($filePath) && $filePath !== '')
+	{
+		$fp = null;
+		$dir = dirname($filePath);
+		try{
+			if(!is_dir($dir))
+			{
+				mkdir($dir,0755,true);
+			}
+			
+			if(($fp = fopen($filePath, 'w')))
+			{
+				
+				for($i=0;$i< 1000000;$i++){
+					fwrite($fp, uniqid() . "\n");
+					fwrite($fp, uniqid() . "\n");
+					if($i % 100 === 0){
+						fflush($fp);
+					}
+				}
+			}
+		}finally{
+			if($fp){
+				fclose($fp);
+			}
+		}
+	}
+}

+ 203 - 0
app/Libs/HuaweiObsSdk/examples/ConcurrentDownloadObjectSample.php

@@ -0,0 +1,203 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to download an object concurrently
+ * from OBS using the OBS SDK for PHP.
+ */
+if (file_exists('vendor/autoload.php')) {
+    require 'vendor/autoload.php';
+} else {
+    require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists('obs-autoloader.php')) {
+    require 'obs-autoloader.php';
+} else {
+    require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$objectKey = 'my-obs-object-key-demo';
+
+$localFilePath = '/temp/' . $objectKey;
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory([ 
+        'key' => $ak,
+        'secret' => $sk,
+        'endpoint' => $endpoint,
+        'socket_timeout' => 30,
+        'connect_timeout' => 10
+]);
+
+try {
+    /*
+     * Create bucket
+     */
+    printf("Create a new bucket for demo\n\n");
+    $obsClient->createBucket([ 
+            'Bucket' => $bucketName
+    ]);
+
+    $sampleFilePath = '/temp/test.txt'; // sample large file path
+                                        // you can prepare a large file in you filesystem first
+    createSampleFile($sampleFilePath);
+
+    /*
+     * Upload an object to your bucket
+     */
+    printf("Uploading a new object to OBS from a file\n\n");
+    $obsClient->putObject([ 
+            'Bucket' => $bucketName,
+            'Key' => $objectKey,
+            'SourceFile' => $sampleFilePath
+    ]);
+
+    /*
+     * Get size of the object and pre-create a random access file to hold object data
+     */
+    $resp = $obsClient->getObjectMetadata([ 
+            'Bucket' => $bucketName,
+            'Key' => $objectKey
+    ]);
+
+    $objectSize = $resp ['ContentLength'];
+
+    printf("Object size from metadata:%d\n\n", $objectSize);
+
+    $dir = dirname($localFilePath);
+    if (! is_dir($dir)) {
+        mkdir($dir, 0755, true);
+    }
+
+    /*
+     * Calculate how many blocks to be divided
+     */
+    $blockSize = 5 * 1024 * 1024; // 5MB
+    $blockCount = intval($objectSize / $blockSize);
+
+    if ($objectSize % $blockSize !== 0) {
+        $blockCount ++;
+    }
+
+    printf("Total blocks count:%d\n\n", $blockCount);
+
+    /*
+     * Download the object concurrently
+     */
+    printf("Start to download %s\n\n", $objectKey);
+
+    $fp = fopen($localFilePath, 'w');
+    $promise = null;
+
+    for($i = 0; $i < $blockCount;) {
+        $startPos = $i ++ * $blockSize;
+        $endPos = ($i == $blockCount) ? $objectSize - 1 : ($i * $blockSize - 1);
+        $range = sprintf('bytes=%d-%d', $startPos, $endPos);
+        $p = $obsClient->getObjectAsync([ 
+                'Bucket' => $bucketName,
+                'Key' => $objectKey,
+                'Range' => $range
+        ], function ($exception, $resp) use ($startPos, $fp, $i, $range) {
+            fseek($fp, $startPos, 0);
+            printf("%s\n", $range);
+            try {
+                while ( ! $resp ['Body']->eof() ) {
+                    $str = $resp ['Body']->read(65536);
+                    fwrite($fp, $str);
+                }
+            } catch ( Exception $exception ) {
+                printf($exception);
+            }
+            $resp ['Body']->close();
+            printf("Part#" . strval($i) . " done\n\n");
+        });
+        if ($promise === null) {
+            $promise = $p;
+        }
+    }
+
+    /*
+     * Waiting for all blocks finished
+     */
+    $promise->wait();
+    fclose($fp);
+    if (file_exists($sampleFilePath)) {
+        unlink($sampleFilePath);
+    }
+
+    /*
+     * Deleting object
+     */
+    printf("Deleting object %s \n\n", $objectKey);
+    $obsClient->deleteObject([ 
+            'Bucket' => $bucketName,
+            'Key' => $objectKey
+    ]);
+} catch ( ObsException $e ) {
+    echo 'Response Code:' . $e->getStatusCode() . PHP_EOL;
+    echo 'Error Message:' . $e->getExceptionMessage() . PHP_EOL;
+    echo 'Error Code:' . $e->getExceptionCode() . PHP_EOL;
+    echo 'Request ID:' . $e->getRequestId() . PHP_EOL;
+    echo 'Exception Type:' . $e->getExceptionType() . PHP_EOL;
+} finally{
+    $obsClient->close();
+}
+
+function createSampleFile($filePath) {
+    if (file_exists($filePath)) {
+        return;
+    }
+    $filePath = iconv('UTF-8', 'GBK', $filePath);
+    if (is_string($filePath) && $filePath !== '') {
+        $fp = null;
+        $dir = dirname($filePath);
+        try {
+            if (! is_dir($dir)) {
+                mkdir($dir, 0755, true);
+            }
+
+            if (($fp = fopen($filePath, 'w'))) {
+
+                for($i = 0; $i < 1000000; $i ++) {
+                    fwrite($fp, uniqid() . "\n");
+                    fwrite($fp, uniqid() . "\n");
+                    if ($i % 100 === 0) {
+                        fflush($fp);
+                    }
+                }
+            }
+        } finally{
+            if ($fp) {
+                fclose($fp);
+            }
+        }
+    }
+}

+ 215 - 0
app/Libs/HuaweiObsSdk/examples/ConcurrentUploadPartSample.php

@@ -0,0 +1,215 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to multipart upload an object concurrently
+ * from OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$objectKey = 'my-obs-object-key-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	
+	/*
+	 * Create bucket
+	 */
+	printf("Create a new bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	/*
+	 * Claim a upload id firstly
+	 */
+	$resp = $obsClient -> initiateMultipartUpload(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	
+	$uploadId = $resp['UploadId'];
+	printf("Claiming a new upload id %s\n\n", $uploadId);
+	
+	$sampleFilePath = '/temp/test.txt'; //sample large file path
+	//  you can prepare a large file in you filesystem first
+	createSampleFile($sampleFilePath);
+	
+	$partSize = 5 * 1024 * 1024;
+	$fileLength = filesize($sampleFilePath);
+	
+	$partCount = $fileLength % $partSize === 0 ?  intval($fileLength / $partSize) : intval($fileLength / $partSize) + 1;
+	
+	if($partCount > 10000){
+		throw new \RuntimeException('Total parts count should not exceed 10000');
+	}
+	
+	printf("Total parts count %d\n\n", $partCount);
+	$parts = [];
+	$promise = null;
+	/*
+	 * Upload multiparts to your bucket
+	 */
+	printf("Begin to upload multiparts to OBS from a file\n\n");
+	for($i = 0; $i < $partCount; $i++){
+		$offset = $i * $partSize;
+		$currPartSize = ($i + 1 === $partCount) ? $fileLength - $offset : $partSize;
+		$partNumber = $i + 1;
+		$p = $obsClient -> uploadPartAsync([
+				'Bucket' => $bucketName, 
+				'Key' => $objectKey, 
+				'UploadId' => $uploadId, 
+				'PartNumber' => $partNumber,
+				'SourceFile' => $sampleFilePath,
+				'Offset' => $offset,
+				'PartSize' => $currPartSize
+		], function($exception, $resp) use(&$parts, $partNumber) {
+			$parts[] = ['PartNumber' => $partNumber, 'ETag' => $resp['ETag']];
+			printf ( "Part#" . strval ( $partNumber ) . " done\n\n" );
+		});
+		
+		if($promise === null){
+			$promise = $p;
+		}
+	}
+	
+	/*
+	 * Waiting for all parts finished
+	 */
+	$promise -> wait();
+	
+	usort($parts, function($a, $b){
+		if($a['PartNumber'] === $b['PartNumber']){
+			return 0;
+		}
+		return $a['PartNumber'] > $b['PartNumber'] ? 1 : -1;
+	});
+	
+	/*
+	 * Verify whether all parts are finished
+	 */
+	if(count($parts) !== $partCount){
+		throw new \RuntimeException('Upload multiparts fail due to some parts are not finished yet');
+	}
+	
+	
+	printf("Succeed to complete multiparts into an object named %s\n\n", $objectKey);
+	
+	/*
+	 * View all parts uploaded recently
+	 */
+	printf("Listing all parts......\n");
+	$resp = $obsClient -> listParts(['Bucket' => $bucketName, 'Key' => $objectKey, 'UploadId' => $uploadId]);
+	foreach ($resp['Parts'] as $part)
+	{
+		printf("\tPart#%d, ETag=%s\n", $part['PartNumber'], $part['ETag']);
+	}
+	printf("\n");
+	
+	
+	/*
+	 * Complete to upload multiparts
+	 */
+	$resp = $obsClient->completeMultipartUpload([
+			'Bucket' => $bucketName,
+			'Key' => $objectKey,
+			'UploadId' => $uploadId,
+			'Parts'=> $parts
+	]);
+	
+// 	deleteTempFile($sampleFilePath);
+	
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}
+
+
+function createSampleFile($filePath)
+{
+	if(file_exists($filePath)){
+		return;
+	}
+	$filePath = iconv('UTF-8', 'GBK', $filePath);
+	if(is_string($filePath) && $filePath !== '')
+	{
+		$fp = null;
+		$dir = dirname($filePath);
+		try{
+			if(!is_dir($dir))
+			{
+				mkdir($dir,0755,true);
+			}
+			
+			if(($fp = fopen($filePath, 'w')))
+			{
+				
+				for($i=0;$i< 1000000;$i++){
+					fwrite($fp, uniqid() . "\n");
+					fwrite($fp, uniqid() . "\n");
+					if($i % 100 === 0){
+						fflush($fp);
+					}
+				}
+			}
+		}finally{
+			if($fp){
+				fclose($fp);
+			}
+		}
+	}
+}
+
+function deleteTempFile($sampleFilePath) {
+    if(file_exists($sampleFilePath)){
+        unlink($sampleFilePath);
+    };
+}

+ 100 - 0
app/Libs/HuaweiObsSdk/examples/CreateFolderSample.php

@@ -0,0 +1,100 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to create an empty folder under
+ * specified bucket to OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$objectKey = 'my-obs-object-key-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	/*
+	 * Create bucket
+	 */
+	echo "Create a new bucket for demo\n\n";
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	
+	/*
+	 * Create an empty folder without request body, note that the key must be
+	 * suffixed with a slash
+	 */
+	$keySuffixWithSlash = "MyObjectKey1/";
+	$obsClient -> putObject(['Bucket' => $bucketName, 'Key' => $keySuffixWithSlash]);
+	echo "Creating an empty folder " . $keySuffixWithSlash . "\n\n";
+	
+	/*
+	 * Verify whether the size of the empty folder is zero
+	 */
+	$resp = $obsClient -> getObject(['Bucket' => $bucketName, 'Key' => $keySuffixWithSlash]);
+	
+	echo "Size of the empty folder '" . $keySuffixWithSlash. "' is " . $resp['ContentLength'] .  "\n\n";
+	if($resp['Body']){
+		$resp['Body'] -> close();
+	}
+	
+	/*
+	 * Create an object under the folder just created
+	 */
+	$obsClient -> putObject(['Bucket' => $bucketName, 'Key' => $keySuffixWithSlash . $objectKey, 'Body' => 'Hello OBS']);
+
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}
+

+ 149 - 0
app/Libs/HuaweiObsSdk/examples/DeleteObjectsSample.php

@@ -0,0 +1,149 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to delete objects under specified bucket
+ * from OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	/*
+	 * Create bucket
+	 */
+	echo "Create a new bucket for demo\n\n";
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	/*
+	 * Batch put objects into the bucket
+	 */
+	$content = 'Thank you for using Object Storage Service';
+	$keyPrefix = 'MyObjectKey';
+	$keys = [];
+	
+	$start = microtime(true);
+	
+// 	doUploadSync($keys, $keyPrefix, $content);
+	
+	doUploadAsync($keys, $keyPrefix, $content);
+	
+	printf("Cost " . round(microtime(true) - $start, 3) * 1000 . " ms to upload 100 objects\n\n");
+	
+	/*
+	 * Delete all objects uploaded recently under the bucket
+	 */
+	
+	printf("Deleting all objects\n\n");
+	
+	$resp = $obsClient->deleteObjects([
+			'Bucket'=>$bucketName,
+			'Objects'=>$keys,
+			'Quiet'=> false,
+	]);
+	
+	printf("Delete results:\n\n");
+	$i = 0;
+	foreach ($resp['Deleteds'] as $delete)
+	{
+		printf("\tDeleteds[$i][Key]:%s,Deleted[$i][VersionId]:%s,Deleted[$i][DeleteMarker]:%s,Deleted[$i][DeleteMarkerVersionId]:%s\n",
+				$delete['Key'],$delete['VersionId'],$delete['DeleteMarker'],$delete['DeleteMarkerVersionId']);
+		$i++;
+	}
+	printf("\n");
+	printf("Error results:\n\n");
+	$i = 0;
+	foreach ($resp['Errors'] as $error)
+	{
+		printf("\tErrors[$i][Key]:%s,Errors[$i][VersionId]:%s,Errors[$i][Code]:%s,Errors[$i][Message]:%s\n",
+				$error['Key'],$error['VersionId'],$error['Code'],$error['Message']);
+		$i++;
+	}
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}
+
+function doUploadSync(&$keys, $keyPrefix, $content)
+{
+	global $obsClient;
+	global $bucketName;
+	for($i = 0;$i < 100;$i++){
+		$key = $keyPrefix . strval($i);
+		$obsClient -> putObject(['Bucket' => $bucketName, 'Key' => $key, 'Body' => $content]);
+		printf("Succeed to put object %s\n\n", $key);
+		$keys[] = ['Key' => $key];
+	}
+}
+
+function doUploadAsync(&$keys, $keyPrefix, $content)
+{
+	global $obsClient;
+	global $bucketName;
+	$promise = null;
+	for($i = 0;$i < 100;$i++){
+		$key = $keyPrefix . strval($i);
+		$p = $obsClient -> putObjectAsync(['Bucket' => $bucketName, 'Key' => $key, 'Body' => $content],
+				function($exception, $resp) use ($key){
+					printf("Succeed to put object %s\n\n", $key);
+				});
+		if($promise === null){
+			$promise = $p;
+		}
+		$keys[] = ['Key' => $key];
+	}
+	$promise -> wait();
+}

+ 101 - 0
app/Libs/HuaweiObsSdk/examples/DownloadSample.php

@@ -0,0 +1,101 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to download an object
+ * from OBS in different ways using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$objectKey = 'my-obs-object-key-demo';
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	/*
+	 * Create bucket
+	 */
+	printf("Create a new bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	/*
+	 * Upload an object to your bucket
+	 */
+	printf("Uploading a new object to OBS\n\n");
+	$content = "abcdefghijklmnopqrstuvwxyz\n\t0123456789011234567890\n";
+	$obsClient -> putObject(['Bucket' => $bucketName, 'Key' => $objectKey, 'Body' => $content]);
+	
+	/*
+	 * Download the object as an inputstream and display it directly
+	 */
+	printf("Downloading an object\n");
+	$resp = $obsClient -> getObject(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	printf("\t%s\n\n", $resp['Body']);
+	
+	
+	/*
+	 * Download the object to a file
+	 */
+	printf("Downloading an object to local file\n");
+	$resp = $obsClient -> getObject(['Bucket' => $bucketName, 'Key' => $objectKey, 'SaveAsFile' => '/temp/' .$objectKey]);
+	printf("\tSaveAsFile:%s\n\n", $resp['SaveAsFile']);
+	
+	
+	printf("Deleting object %s \n\n", $objectKey);
+	$obsClient -> deleteObject(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}

+ 191 - 0
app/Libs/HuaweiObsSdk/examples/ListObjectsInFolderSample.php

@@ -0,0 +1,191 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to list objects under a specified folder of a bucket
+ * from OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	/*
+	 * Create bucket
+	 */
+	printf("Create a new bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	/*
+	 * First prepare folders and sub folders
+	 */
+	$keys = [];
+	$promise = null;
+	$keyPrefix = 'MyObjectKey';
+	$folderPrefix = 'src';
+	$subFolderPrefix = 'test';
+	
+	for($i = 0; $i<5; $i++){
+		$key = $folderPrefix . $i . '/';
+		$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $key]);
+		$keys[] = ['Key' => $key];
+		for($j = 0; $j < 3; $j++){
+			$subKey = $key . $subFolderPrefix . $j . '/';
+			$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $subKey]);
+			$keys[] = ['Key' => $subKey];
+		}
+	}
+	
+	/*
+	 * Insert 2 objects in each folder
+	 */
+	$resp = $obsClient -> listObjects(['Bucket' => $bucketName]);
+	foreach ($resp ['Contents'] as $content ) {
+		for($k =0; $k < 2; $k++){
+			$objectKey = $content['Key'] . $keyPrefix . $k;
+			$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $objectKey, 'Body' => 'Hello OBS']);
+			$keys[] = ['Key' => $objectKey];
+		}
+	}
+	
+	/*
+	 * Insert 2 objects in root path
+	 */
+	$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $keyPrefix . '0', 'Body' =>  'Hello OBS']);
+	$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $keyPrefix . '1', 'Body' =>  'Hello OBS']);
+	printf("Put %d objects completed.\n\n", count($keys));
+	
+	
+	/*
+	 * List all objects in folder src0/
+	 */
+	printf("List all objects in folder src0/\n\n");
+	$resp = $obsClient -> listObjects(['Bucket' => $bucketName, 'Prefix' => 'src0/']);
+	foreach ( $resp ['Contents'] as $content ) {
+		printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
+	}
+	printf("\n");
+	
+	/*
+	 * List all objects in sub folder src0/test0/
+	 */
+	
+	printf("List all objects in folder src0/test0/\n\n");
+	$resp = $obsClient -> listObjects(['Bucket' => $bucketName, 'Prefix' => 'src0/test0/']);
+	foreach ( $resp ['Contents'] as $content ) {
+		printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
+	}
+	printf("\n");
+	
+	/*
+	 * List all objects group by folder
+	 */
+	printf("List all objects group by folder\n\n");
+	$resp = $obsClient -> listObjects(['Bucket' => $bucketName, 'Delimiter' => '/']);
+	printf("Root path:\n");
+	foreach ( $resp ['Contents'] as $content ) {
+		printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
+	}
+	listObjectsByPrefix($resp);
+	printf("\n");
+	
+	/*
+	 * Delete all the objects created
+	 */
+	$resp = $obsClient->deleteObjects([
+			'Bucket'=>$bucketName,
+			'Objects'=>$keys,
+			'Quiet'=> false,
+	]);
+	
+	printf("Delete results:\n\n");
+	$i = 0;
+	foreach ($resp['Deleteds'] as $delete)
+	{
+		printf("\tDeleteds[$i][Key]:%s,Deleted[$i][VersionId]:%s,Deleted[$i][DeleteMarker]:%s,Deleted[$i][DeleteMarkerVersionId]:%s\n",
+				$delete['Key'],$delete['VersionId'],$delete['DeleteMarker'],$delete['DeleteMarkerVersionId']);
+		$i++;
+	}
+	printf("\n");
+	printf("Error results:\n\n");
+	$i = 0;
+	foreach ($resp['Errors'] as $error)
+	{
+		printf("\tErrors[$i][Key]:%s,Errors[$i][VersionId]:%s,Errors[$i][Code]:%s,Errors[$i][Message]:%s\n",
+				$error['Key'],$error['VersionId'],$error['Code'],$error['Message']);
+		$i++;
+	}
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}
+
+
+function listObjectsByPrefix($resp){
+	global $obsClient;
+	global $bucketName;
+	while(!empty($resp ['CommonPrefixes'])){
+		foreach ($resp ['CommonPrefixes'] as $commonPrefix){
+			$commonPrefix = $commonPrefix['Prefix'];
+			printf("Folder %s:\n", $commonPrefix);
+			$resp = $obsClient -> listObjects(['Bucket' => $bucketName, 'Delimiter' => '/', 'Prefix' => $commonPrefix]);
+			foreach ( $resp ['Contents'] as $content ) {
+				printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
+			}
+			listObjectsByPrefix($resp);
+		}
+	}
+	
+}

+ 180 - 0
app/Libs/HuaweiObsSdk/examples/ListObjectsSample.php

@@ -0,0 +1,180 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to list objects under specified bucket
+ * from OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	
+	/*
+	 * Create bucket
+	 */
+	printf("Create a new bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	
+	/*
+	 * First insert 100 objects for demo
+	 */
+	$promise = null;
+	$keyPrefix = 'MyObjectKey';
+	for($i = 0;$i < 100;$i++){
+		$key = $keyPrefix . strval($i);
+		$p = $obsClient -> putObjectAsync(['Bucket' => $bucketName, 'Key' => $key, 'Body' => 'Hello OBS'],function(){});
+		if($promise === null){
+			$promise = $p;
+		}
+		$keys[] = ['Key' => $key];
+	}
+	$promise -> wait();
+	
+	printf("Put %d objects completed.\n\n", count($keys));
+	
+	/*
+	 * List objects using default parameters, will return up to 1000 objects
+	 */
+	printf("List objects using default parameters:\n");
+	
+	$resp = $obsClient -> listObjects(['Bucket' => $bucketName]);
+	foreach ( $resp ['Contents'] as $content ) {
+		printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
+	}
+	printf("\n");
+	
+	/*
+	 * List the first 10 objects
+	 */
+	printf("List the first 10 objects:\n");
+	
+	$resp = $obsClient -> listObjects(['Bucket' => $bucketName, 'MaxKeys' => 10]);
+	foreach ( $resp ['Contents'] as $content ) {
+		printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
+	}
+	printf("\n");
+	
+	$theSecond10ObjectsMarker = $resp['NextMarker'];
+	/*
+	 * List the second 10 objects using marker
+	 */
+	printf("List the second 10 objects using marker:\n");
+	$resp = $obsClient -> listObjects(['Bucket' => $bucketName, 'MaxKeys' => 10, 'Marker' => $theSecond10ObjectsMarker]);
+	foreach ( $resp ['Contents'] as $content ) {
+		printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
+	}
+	printf("\n");
+	
+	/*
+	 * List objects with prefix and max keys
+	 */
+	printf("List objects with prefix and max keys:\n");
+	$resp = $obsClient -> listObjects(['Bucket' => $bucketName, 'MaxKeys' => 5, 'Prefix' => $keyPrefix . '2']);
+	foreach ( $resp ['Contents'] as $content ) {
+		printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
+	}
+	printf("\n");
+	
+	/*
+	 * List all the objects in way of pagination
+	 */
+	printf("List all the objects in way of pagination:\n");
+	$nextMarker = null;
+	$index = 1;
+	do{
+		
+		$resp = $obsClient -> listObjects(['Bucket' => $bucketName, 'MaxKeys' => 10, 'Marker' => $nextMarker]);
+		$nextMarker = $resp['NextMarker'];
+		printf("Page:%d\n", $index++);
+		foreach ( $resp ['Contents'] as $content ) {
+			printf("\t%s etag[%s]\n", $content ['Key'], $content ['ETag']);
+		}
+		
+	}while($resp['IsTruncated']);
+	printf("\n");
+	/*
+	 * Delete all the objects created
+	 */
+	$resp = $obsClient->deleteObjects([
+			'Bucket'=>$bucketName,
+			'Objects'=>$keys,
+			'Quiet'=> false,
+	]);
+	
+	printf("Delete results:\n\n");
+	$i = 0;
+	foreach ($resp['Deleteds'] as $delete)
+	{
+		printf("\tDeleteds[$i][Key]:%s,Deleted[$i][VersionId]:%s,Deleted[$i][DeleteMarker]:%s,Deleted[$i][DeleteMarkerVersionId]:%s\n",
+				$delete['Key'],$delete['VersionId'],$delete['DeleteMarker'],$delete['DeleteMarkerVersionId']);
+		$i++;
+	}
+	printf("\n");
+	printf("Error results:\n\n");
+	$i = 0;
+	foreach ($resp['Errors'] as $error)
+	{
+		printf("\tErrors[$i][Key]:%s,Errors[$i][VersionId]:%s,Errors[$i][Code]:%s,Errors[$i][Message]:%s\n",
+				$error['Key'],$error['VersionId'],$error['Code'],$error['Message']);
+		$i++;
+	}
+	
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}

+ 236 - 0
app/Libs/HuaweiObsSdk/examples/ListVersionsSample.php

@@ -0,0 +1,236 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to list versions under specified bucket
+ * from OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	/*
+	 * Create bucket
+	 */
+	printf("Create a new bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	/*
+	 * Enable bucket versioning
+	 */
+	$obsClient -> setBucketVersioningConfiguration(['Bucket' => $bucketName, 'Status' => 'Enabled']);
+	
+	/*
+	 * First prepare folders and sub folders
+	 */
+	$keys = [];
+	$promise = null;
+	$keyPrefix = 'MyObjectKey';
+	$folderPrefix = 'src';
+	$subFolderPrefix = 'test';
+	
+	for($i = 0; $i<5; $i++){
+		$key = $folderPrefix . $i . '/';
+		$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $key]);
+		$keys[] = ['Key' => $key];
+		for($j = 0; $j < 3; $j++){
+			$subKey = $key . $subFolderPrefix . $j . '/';
+			$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $subKey]);
+			$keys[] = ['Key' => $subKey];
+		}
+	}
+	
+	/*
+	 * Insert 2 objects in each folder
+	 */
+	$resp = $obsClient -> listObjects(['Bucket' => $bucketName]);
+	foreach ($resp ['Contents'] as $content ) {
+		for($k =0; $k < 2; $k++){
+			$objectKey = $content['Key'] . $keyPrefix . $k; 
+			$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $objectKey, 'Body' => 'Hello OBS']);
+			$keys[] = ['Key' => $objectKey];
+		}
+	}
+	
+	/*
+	 * Insert 2 objects in root path
+	 */
+	$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $keyPrefix . '0', 'Body' =>  'Hello OBS']);
+	$obsClient -> putObject(['Bucket'=>$bucketName, 'Key' => $keyPrefix . '1', 'Body' =>  'Hello OBS']);
+	
+	printf("Put %d objects completed.\n\n", count($keys));
+	
+	
+	$keys = [];
+	
+	/*
+	 * List versions using default parameters, will return up to 1000 objects
+	 */
+	$resp = $obsClient -> listVersions (['Bucket' => $bucketName ]);
+	printf("\tVersions:\n");
+	foreach ( $resp ['Versions'] as $version ) {
+		printf("\t%s etag[%s] versionid[%s]\n", $version['Key'], $version['ETag'],$version['VersionId']);
+		$keys[] = ['Key' => $version['Key'], 'VersionId' => $version['VersionId']];
+	}
+	printf("\n");
+	
+	printf("\tDeleteMarkers:\n");
+	foreach ( $resp ['DeleteMarkers'] as $deleteMarker ) {
+		printf("\t%s versionid[%s]\n", $deleteMarker['Key'], $deleteMarker['VersionId']);
+		$keys[] = ['Key' => $deleteMarker['Key'], 'VersionId' => $deleteMarker['VersionId']];
+	}
+	printf("\n");
+	
+	
+	/*
+	 * List all the versions in way of pagination
+	 */
+	printf("List all the versions in way of pagination:\n");
+	$nextMarker = null;
+	$index = 1;
+	do{
+		$resp = $obsClient -> listVersions(['Bucket' => $bucketName, 'MaxKeys' => 10, 'KeyMarker' => $nextMarker]);
+		$nextMarker = $resp['NextKeyMarker'];
+		printf("Page:%d\n", $index++);
+		
+		printf("\tVersions:\n");
+		foreach ( $resp ['Versions'] as $version ) {
+			printf("\t%s etag[%s] versionid[%s]\n", $version['Key'], $version['ETag'],$version['VersionId']);
+		}
+		
+		printf("\n");
+		printf("\tDeleteMarkers:\n");
+		foreach ( $resp ['DeleteMarkers'] as $deleteMarker ) {
+			printf("\t%s versionid[%s]\n", $deleteMarker['Key'], $deleteMarker['VersionId']);
+		}
+	}while($resp['IsTruncated']);
+	printf("\n");
+	
+	/*
+	 * List all versions group by folder
+	 */
+	printf("List all versions group by folder \n");
+	$resp = $obsClient -> listVersions(['Bucket' => $bucketName, 'Delimiter' => '/']);
+	
+	printf("Root path:\n");
+	printf("\tVersions:\n");
+	foreach ( $resp ['Versions'] as $version ) {
+		printf("\t%s etag[%s] versionid[%s]\n", $version['Key'], $version['ETag'],$version['VersionId']);
+	}
+	
+	printf("\n");
+	printf("\tDeleteMarkers:\n");
+	foreach ( $resp ['DeleteMarkers'] as $deleteMarker ) {
+		printf("\t%s versionid[%s]\n", $deleteMarker['Key'], $deleteMarker['VersionId']);
+	}
+	
+	listVersionsByPrefix($resp);
+	
+	
+	printf("\n");
+	/*
+	 * Delete all the objects created
+	 */
+	$resp = $obsClient->deleteObjects([
+			'Bucket'=>$bucketName,
+			'Objects'=>$keys,
+			'Quiet'=> false,
+	]);
+	
+	printf("Delete results:\n\n");
+	$i = 0;
+	foreach ($resp['Deleteds'] as $delete)
+	{
+		printf("\tDeleteds[$i][Key]:%s,Deleted[$i][VersionId]:%s,Deleted[$i][DeleteMarker]:%s,Deleted[$i][DeleteMarkerVersionId]:%s\n",
+				$delete['Key'],$delete['VersionId'],$delete['DeleteMarker'],$delete['DeleteMarkerVersionId']);
+		$i++;
+	}
+	printf("\n");
+	printf("Error results:\n\n");
+	$i = 0;
+	foreach ($resp['Errors'] as $error)
+	{
+		printf("\tErrors[$i][Key]:%s,Errors[$i][VersionId]:%s,Errors[$i][Code]:%s,Errors[$i][Message]:%s\n",
+				$error['Key'],$error['VersionId'],$error['Code'],$error['Message']);
+		$i++;
+	}
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}
+
+function listVersionsByPrefix($resp){
+	global $obsClient;
+	global $bucketName;
+	while(!empty($resp ['CommonPrefixes'])){
+		foreach ($resp ['CommonPrefixes'] as $commonPrefix){
+			$commonPrefix = $commonPrefix['Prefix'];
+			printf("Folder %s:\n", $commonPrefix);
+			$resp = $obsClient -> listVersions(['Bucket' => $bucketName, 'Delimiter' => '/', 'Prefix' => $commonPrefix]);
+			printf("\tVersions:\n");
+			foreach ( $resp ['Versions'] as $version ) {
+				printf("\t%s etag[%s] versionid[%s]\n", $version['Key'], $version['ETag'],$version['VersionId']);
+			}
+			printf("\n");
+			printf("\tDeleteMarkers:\n");
+			foreach ( $resp ['DeleteMarkers'] as $deleteMarker ) {
+				printf("\t%s versionid[%s]\n", $deleteMarker['Key'], $deleteMarker['VersionId']);
+			}
+			listVersionsByPrefix($resp);
+		}
+	}
+	
+}

+ 107 - 0
app/Libs/HuaweiObsSdk/examples/ObjectMetaSample.php

@@ -0,0 +1,107 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to set/get self-defined metadata for object
+ * on OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$objectKey = 'my-obs-object-key-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	/*
+	 * Create bucket
+	 */
+	printf("Create a new bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	/*
+	 * Create object
+	 */
+	$content = 'Hello OBS';
+	
+	/*
+	 * Setting self-defined metadata
+	 */
+	
+	$metadata = [];
+	
+	$metadata['meta1'] = 'value1';
+	$metadata['meta2'] = 'value2';
+	$obsClient -> putObject(['Bucket' => $bucketName, 'Key' => $objectKey, 'Body' => $content, 'Metadata' => $metadata]);
+	
+	printf("Create object %s successfully!\n\n", $objectKey);
+	
+	/*
+	 * Get object metadata
+	 */
+	$resp = $obsClient -> getObjectMetadata(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	printf("Getting object metadata:\n");
+	foreach ($resp['Metadata'] as $key => $value){
+		printf("\t%s=%s\n", $key, $value);
+	}
+	
+	/*
+	 * Delete object
+	 */
+	$obsClient -> deleteObject(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}

+ 187 - 0
app/Libs/HuaweiObsSdk/examples/ObjectOperationsSample.php

@@ -0,0 +1,187 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to do object-related operations
+ * (such as create/delete/get/copy object, do object ACL/OPTIONS)
+ * on OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$objectKey = 'my-obs-object-key-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	/*
+	 * Create bucket
+	 */
+	printf("Create a new bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	/*
+	 * Create object
+	 */
+	$content = 'Hello OBS';
+	$obsClient -> putObject(['Bucket' => $bucketName, 'Key' => $objectKey, 'Body' => $content]);
+	printf("Create object: %s successfully!\n\n", $objectKey);
+	
+	
+	/*
+	 * Get object metadata
+	 */
+	printf("Getting object metadata\n");
+	$resp = $obsClient->getObjectMetadata([
+			'Bucket'=>$bucketName,
+			'Key'=>$objectKey,
+	]);
+	printf("\tMetadata:%s\n\n", json_encode($resp));
+	
+	/*
+	 * Get object
+	 */
+	printf("Getting object content\n");
+	$resp = $obsClient -> getObject(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	printf("\t%s\n\n", $resp['Body']);
+	
+	/*
+	 * Copy object
+	 */
+	$sourceBucketName = $bucketName;
+	$destBucketName = $bucketName;
+	$sourceObjectKey = $objectKey;
+	$destObjectKey = $objectKey . '-back';
+	printf("Copying object\n\n");
+	$obsClient -> copyObject([				
+			'Bucket'=> $destBucketName,
+			'Key'=> $destObjectKey,
+			'CopySource'=>$sourceBucketName . '/' . $sourceObjectKey,
+			'MetadataDirective' => ObsClient::CopyMetadata
+	]);
+	
+	/*
+	 * Options object
+	 */
+	doObjectOptions();
+	
+	/*
+	 * Put/Get object acl operations
+	 */
+	doObjectAclOperations();
+	
+	/*
+	 * Delete object
+	 */
+	printf("Deleting objects\n\n");
+	$obsClient -> deleteObject(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	$obsClient -> deleteObject(['Bucket' => $bucketName, 'Key' => $destObjectKey]);
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}
+
+function doObjectOptions()
+{
+	
+	global $obsClient;
+	global $bucketName;
+	global $objectKey;
+	
+	$obsClient->setBucketCors ( [
+			'Bucket' => $bucketName,
+			'CorsRule' => [
+					[
+							'AllowedMethod' => ['HEAD', 'GET', 'PUT'],
+							'AllowedOrigin' => ['http://www.a.com', 'http://www.b.com'],
+							'AllowedHeader'=> ['Authorization'],
+							'ExposeHeaders' => ['x-obs-test1', 'x-obs-test2'],
+							'MaxAgeSeconds' => 100
+					]
+			]
+	] );
+	
+	$resp = $obsClient->optionsObject([
+			'Bucket'=>$bucketName,
+			'Key' => $objectKey,
+			'Origin'=>'http://www.a.com',
+			'AccessControlRequestMethods' => ['PUT'],
+			'AccessControlRequestHeaders'=> ['Authorization']
+	]);
+	printf ("Options bucket: %s\n\n", json_encode($resp -> toArray()));
+
+}
+
+function doObjectAclOperations()
+{
+	global $obsClient;
+	global $bucketName;
+	global $objectKey;
+	
+	printf("Setting object ACL to " . ObsClient::AclPublicRead . "\n\n");
+	
+	$obsClient ->setObjectAcl([
+			'Bucket' => $bucketName,
+			'Key' => $objectKey,
+			'ACL' => ObsClient::AclPublicRead
+	]);
+	
+	printf("Getting object ACL\n");
+	$resp = $obsClient -> getObjectAcl([
+			'Bucket' => $bucketName,
+			'Key' => $objectKey
+	]);
+	printf("\tOwner:%s\n", json_encode($resp['Owner']));
+	printf("\tGrants:%s\n\n", json_encode($resp['Grants']));
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1406 - 0
app/Libs/HuaweiObsSdk/examples/ObsPhpDemo.php


+ 227 - 0
app/Libs/HuaweiObsSdk/examples/PostObjectSample.php

@@ -0,0 +1,227 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to post object under specified bucket from
+ * OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+    require 'vendor/autoload.php';
+} else {
+    require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+    require 'obs-autoloader.php';
+} else {
+    require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use GuzzleHttp\Client;
+use GuzzleHttp\Exception\ClientException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$objectKey = 'my-obs-object-key-demo';
+
+$signature = 'obs';
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+        'key' => $ak,
+        'secret' => $sk,
+        'endpoint' => $endpoint,
+        'socket_timeout' => 30,
+        'connect_timeout' => 10,
+        'signature' => $signature
+]);
+
+/*
+ * Create bucket
+ */
+printf("Create a new bucket for demo\n\n");
+$obsClient -> createBucket(['Bucket' => $bucketName]);
+
+
+/*
+ * Create sample file
+ */
+$sampleFilePath = '/temp/text.txt';
+createSampleFile($sampleFilePath);
+
+/*
+ * Claim a post object request
+ */
+$formParams = [];
+if (strcasecmp($signature, 'obs') === 0) {
+    $formParams['x-obs-acl'] = ObsClient::AclPublicRead;
+} else {
+    $formParams['acl'] = ObsClient::AclPublicRead;
+}
+$formParams['content-type'] = 'text/plain';
+
+$res = $obsClient -> createPostSignature(['Bucket' => $bucketName, 'Key' => $objectKey, 'Expires' => 3600, 'FormParams' => $formParams]);
+
+$formParams['key'] = $objectKey;
+$formParams['policy'] = $res['Policy'];
+
+if (strcasecmp($signature, 'obs') === 0) {
+    $formParams['Accesskeyid'] = $ak;
+} else {
+    $formParams['AWSAccesskeyid'] = $ak;
+}
+
+$formParams['signature'] = $res['Signature'];
+
+
+printf("Creating object in browser-based post way\n\n");
+$boundary = '9431149156168';
+
+$buffers = [];
+$contentLength = 0;
+
+/*
+ * Construct form data
+ */
+$buffer = [];
+$first = true;
+foreach ($formParams as $key => $val){
+    if(!$first){
+        $buffer[] = "\r\n";
+    }else{
+        $first = false;
+    }
+    
+    $buffer[] = "--";
+    $buffer[] = $boundary;
+    $buffer[] = "\r\n";
+    $buffer[] = "Content-Disposition: form-data; name=\"";
+    $buffer[] = strval($key);
+    $buffer[] = "\"\r\n\r\n";
+    $buffer[] = strval($val);
+}
+
+$buffer = implode('', $buffer);
+$contentLength += strlen($buffer);
+$buffers[] = $buffer;
+
+/*
+ * Construct file description
+ */
+$buffer = [];
+
+$buffer[] = "\r\n";
+$buffer[] = "--";
+$buffer[] = $boundary;
+$buffer[] = "\r\n";
+$buffer[] = "Content-Disposition: form-data; name=\"file\"; filename=\"";
+$buffer[] = "myfile";
+$buffer[] = "\"\r\n";
+$buffer[] = "Content-Type: text/plain";
+$buffer[] = "\r\n\r\n";
+
+$buffer = implode('', $buffer);
+$contentLength += strlen($buffer);
+$buffers[] = $buffer;
+
+/*
+ * Construct file data
+ */
+$buffer = [];
+
+$fp = fopen($sampleFilePath, 'r');
+if($fp){
+    while(!feof($fp)){
+        $buffer[] = fgetc($fp);
+    }
+    fclose($fp);
+}
+
+$buffer = implode('', $buffer);
+$contentLength += strlen($buffer);
+$buffers[] = $buffer;
+
+/*
+ * Contruct end data
+ */
+$buffer = [];
+$buffer[] = "\r\n--";
+$buffer[] = $boundary;
+$buffer[] = "--\r\n";
+
+$buffer = implode('', $buffer);
+$contentLength += strlen($buffer);
+$buffers[] = $buffer;
+
+
+$httpClient = new Client(['verify' => false]);
+$host = parse_url($endpoint)['host'];
+$host = $bucketName . '.' . $host;
+$url = 'https://' . $host . ':443';
+$headers = ['Content-Length' => strval($contentLength), 'Content-Type' => 'multipart/form-data; boundary=' . $boundary];
+
+try{
+    $response = $httpClient -> request('POST', $url, ['body' => implode('', $buffers), 'headers'=> $headers]);
+    
+    printf('Post object successfully!');
+    $response -> getBody()-> close();
+}catch (ClientException $ex){
+    printf('Exception message:%s', $ex ->getMessage());
+}
+
+
+if(file_exists($sampleFilePath)){
+    unlink($sampleFilePath);
+}
+
+function createSampleFile($filePath)
+{
+    if(file_exists($filePath)){
+        return;
+    }
+    $filePath = iconv('UTF-8', 'GBK', $filePath);
+    if(is_string($filePath) && $filePath !== '')
+    {
+        $fp = null;
+        $dir = dirname($filePath);
+        try{
+            if(!is_dir($dir))
+            {
+                mkdir($dir,0755,true);
+            }
+            
+            if(($fp = fopen($filePath, 'w+')))
+            {
+                fwrite($fp, uniqid() . "\n");
+                fwrite($fp, uniqid() . "\n");
+            }
+        }finally{
+            if($fp){
+                fclose($fp);
+            }
+        }
+    }
+}

+ 110 - 0
app/Libs/HuaweiObsSdk/examples/RestoreObjectSample.php

@@ -0,0 +1,110 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to download an cold object
+ * from OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-cold-bucket-demo';
+
+$objectKey = 'my-obs-cold-object-key-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	/*
+	 * Create a cold bucket
+	 */
+	printf("Create a new cold bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName, 'StorageClass' => ObsClient::StorageClassCold]);
+	
+	/*
+	 * Create a cold object
+	 */
+	printf("Create a new cold object for demo\n\n");
+	$content = 'Hello OBS';
+	$obsClient -> putObject(['Bucket' => $bucketName, 'Key' => $objectKey, 'Body' => $content]);
+	
+	/*
+	 * Restore the cold object
+	 */
+	printf("Restore the cold object\n\n");
+	$obsClient -> restoreObject([
+			'Bucket' => $bucketName,
+			'Key' => $objectKey,
+			'Days' => 1,
+	    'Tier' => ObsClient::RestoreTierExpedited
+	]);
+	
+	/*
+	 * Wait 6 minute to get the object
+	 */
+	sleep(60 * 6);
+	
+	/*
+	 * Get the cold object
+	 */
+	printf("Get the cold object\n");
+	$resp = $obsClient -> getObject(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	printf("\t%s\n\n", $resp['Body']);
+	
+	/*
+	 * Delete the cold object
+	 */
+	$obsClient -> deleteObject(['Bucket' => $bucketName, 'Key' => $objectKey]);
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}

+ 109 - 0
app/Libs/HuaweiObsSdk/examples/SimpleMultipartUploadSample.php

@@ -0,0 +1,109 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to upload multiparts to OBS
+ * using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use Obs\ObsException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$objectKey = 'my-obs-object-key-demo';
+
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+try
+{
+	printf("Create a new bucket for demo\n\n");
+	$obsClient -> createBucket(['Bucket' => $bucketName]);
+	
+	/*
+	 * Step 1: initiate multipart upload
+	 */
+	printf("Step 1: initiate multipart upload\n\n");
+	
+	$resp = $obsClient -> initiateMultipartUpload(['Bucket'=>$bucketName,
+			'Key'=>$objectKey]);
+	
+	$uploadId = $resp['UploadId'];
+	/*
+	 * Step 2: upload a part
+	 */
+	printf("Step 2: upload a part\n\n");
+	$resp = $obsClient->uploadPart([
+			'Bucket'=>$bucketName,
+			'Key' => $objectKey,
+			'UploadId'=>$uploadId,
+			'PartNumber'=>1,
+			'Body' => 'Hello OBS'
+	]);
+	
+	$etag = $resp['ETag'];
+	
+	/*
+	 * Step 3: complete multipart upload
+	 */
+	printf("Step 3: complete multipart upload\n\n");
+	$obsClient->completeMultipartUpload([
+			'Bucket'=>$bucketName,
+			'Key'=>$objectKey,
+			'UploadId'=>$uploadId,
+			'Parts'=>[
+					['PartNumber'=>1,'ETag'=>$etag]
+			],
+	]);
+	
+	
+} catch ( ObsException $e ) {
+	echo 'Response Code:' . $e->getStatusCode () . PHP_EOL;
+	echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL;
+	echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL;
+	echo 'Request ID:' . $e->getRequestId () . PHP_EOL;
+	echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL;
+} finally{
+	$obsClient->close ();
+}

+ 151 - 0
app/Libs/HuaweiObsSdk/examples/TemporarySignatureSample.php

@@ -0,0 +1,151 @@
+<?php
+
+/**
+ * Copyright 2019 Huawei Technologies Co.,Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ * this file except in compliance with the License.  You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ */
+
+/**
+ * This sample demonstrates how to do common operations in temporary signature way
+ * on OBS using the OBS SDK for PHP.
+ */
+if (file_exists ( 'vendor/autoload.php' )) {
+	require 'vendor/autoload.php';
+} else {
+	require '../vendor/autoload.php'; // sample env
+}
+
+if (file_exists ( 'obs-autoloader.php' )) {
+	require 'obs-autoloader.php';
+} else {
+	require '../obs-autoloader.php'; // sample env
+}
+
+use Obs\ObsClient;
+use GuzzleHttp\Client;
+use GuzzleHttp\Exception\ClientException;
+
+$ak = '*** Provide your Access Key ***';
+
+$sk = '*** Provide your Secret Key ***';
+
+$endpoint = 'https://your-endpoint:443';
+
+$bucketName = 'my-obs-bucket-demo';
+
+$objectKey = 'my-obs-object-key-demo';
+
+/*
+ * Constructs a obs client instance with your account for accessing OBS
+ */
+$obsClient = ObsClient::factory ( [
+		'key' => $ak,
+		'secret' => $sk,
+		'endpoint' => $endpoint,
+		'socket_timeout' => 30,
+		'connect_timeout' => 10
+] );
+
+$httpClient = new Client(['verify' => false]);
+
+/*
+ * Create bucket
+ */
+$method = 'PUT';
+$res = $obsClient -> createSignedUrl(['Bucket' => $bucketName, 'Method' => $method]);
+doAction('Create bucket', $method, $res['SignedUrl']);
+
+/*
+ * Set/Get/Delete bucket cors
+ */
+$method = 'PUT';
+$content = '<CORSConfiguration><CORSRule><AllowedMethod>PUT</AllowedMethod><AllowedOrigin>http://www.a.com</AllowedOrigin><AllowedHeader>header1</AllowedHeader><MaxAgeSeconds>100</MaxAgeSeconds><ExposeHeader>header2</ExposeHeader></CORSRule></CORSConfiguration>';
+$headers = ['Content-Length'=> strval(strlen($content)), 'Content-MD5' => base64_encode(md5($content, true))];
+$res = $obsClient -> createSignedUrl(['Bucket' => $bucketName, 'Method' => $method, 'SpecialParam' => 'cors', 'Headers' => $headers]);
+doAction('Set bucket cors ', $method, $res['SignedUrl'], $content, $res['ActualSignedRequestHeaders']);
+
+
+$method = 'GET';
+$res= $obsClient -> createSignedUrl(['Bucket' => $bucketName, 'Method' => $method, 'SpecialParam' => 'cors']);
+doAction('Get bucket cors ', $method, $res['SignedUrl']);
+
+$method = 'DELETE';
+$res= $obsClient -> createSignedUrl(['Bucket' => $bucketName, 'Method' => $method, 'SpecialParam' => 'cors']);
+doAction('Delete bucket cors ', $method, $res['SignedUrl']);
+
+/*
+ * Create object
+ */
+$method = 'PUT';
+$content = 'Hello OBS';
+$headers = ['Content-Length'=> strval(strlen($content))];
+$res = $obsClient -> createSignedUrl(['Method' => $method, 'Bucket' => $bucketName, 'Key' => $objectKey, 'Headers'=> $headers]);
+doAction('Create object', $method, $res['SignedUrl'], $content, $res['ActualSignedRequestHeaders']);
+		
+
+/*
+ * Get object
+ */
+$method = 'GET';
+$res = $obsClient -> createSignedUrl(['Method' => $method, 'Bucket' => $bucketName, 'Key' => $objectKey]);
+doAction('Get object', $method, $res['SignedUrl']);
+
+/*
+ * Set/Get object acl 
+ */
+$method = 'PUT';
+$headers = ['x-amz-acl'=> ObsClient::AclPublicRead];
+$res = $obsClient -> createSignedUrl(['Method' => $method, 'Bucket' => $bucketName, 'Key' => $objectKey, 'Headers'=> $headers, 'SpecialParam' => 'acl']);
+doAction('Set object Acl', $method, $res['SignedUrl'], null, $res['ActualSignedRequestHeaders']);
+
+
+$method = 'GET';
+$res = $obsClient -> createSignedUrl(['Method' => $method, 'Bucket' => $bucketName, 'Key' => $objectKey, 'SpecialParam' => 'acl']);
+doAction('Get object Acl', $method, $res['SignedUrl']);
+
+/*
+ * Delete object
+ */
+$method = 'DELETE';
+$res = $obsClient -> createSignedUrl(['Method' => $method, 'Bucket' => $bucketName, 'Key' => $objectKey]);
+doAction('Delete object', $method, $res['SignedUrl']);
+
+/*
+ * Delete bucket
+ */
+$method = 'DELETE';
+$res = $obsClient -> createSignedUrl(['Bucket' => $bucketName, 'Method' => $method]);
+doAction('Delete bucket', $method, $res['SignedUrl']);
+
+
+function doAction($msg, $method, $url, $content=null, $headers=null){
+	global $httpClient;
+	
+	try{
+		$response = $httpClient -> request($method, $url, ['body' => $content, 'headers'=> $headers]);
+		printf("%s using temporary signature url:\n", $msg);
+		printf("\t%s successfully.\n", $url);
+		printf("\tStatus:%d\n", $response -> getStatusCode());
+		printf("\tContent:%s\n", $response -> getBody() -> getContents());
+		$response -> getBody()-> close();
+	}catch (ClientException $ex){
+		printf("%s using temporary signature url:\n", $msg);
+		printf("\t%s failed!\n", $url);
+		printf('Exception message:%s', $ex ->getMessage());
+	}
+
+	printf("\n");
+}
+
+ 
+

+ 34 - 0
app/Libs/HuaweiObsSdk/obs-autoloader.php

@@ -0,0 +1,34 @@
+<?php
+

+$mapping = [
+	'Obs\Internal\Common\CheckoutStream' => __DIR__.'/Obs/Internal/Common/CheckoutStream.php',
+	'Obs\Internal\Common\ITransform' => __DIR__.'/Obs/Internal/Common/ITransform.php',
+	'Obs\Internal\Common\Model' => __DIR__.'/Obs/Internal/Common/Model.php',
+	'Obs\Internal\Common\ObsTransform' => __DIR__.'/Obs/Internal/Common/ObsTransform.php',
+	'Obs\Internal\Common\SchemaFormatter' => __DIR__.'/Obs/Internal/Common/SchemaFormatter.php',
+	'Obs\Internal\Common\SdkCurlFactory' => __DIR__.'/Obs/Internal/Common/SdkCurlFactory.php',
+	'Obs\Internal\Common\SdkStreamHandler' => __DIR__.'/Obs/Internal/Common/SdkStreamHandler.php',
+	'Obs\Internal\Common\ToArrayInterface' => __DIR__.'/Obs/Internal/Common/ToArrayInterface.php',
+	'Obs\Internal\Common\V2Transform' => __DIR__.'/Obs/Internal/Common/V2Transform.php',
+	'Obs\Internal\GetResponseTrait' => __DIR__.'/Obs/Internal/GetResponseTrait.php',
+	'Obs\Internal\Resource\Constants' => __DIR__.'/Obs/Internal/Resource/Constants.php',
+	'Obs\Internal\Resource\OBSConstants' => __DIR__.'/Obs/Internal/Resource/OBSConstants.php',
+	'Obs\Internal\Resource\OBSRequestResource' => __DIR__.'/Obs/Internal/Resource/OBSRequestResource.php',
+	'Obs\Internal\Resource\V2Constants' => __DIR__.'/Obs/Internal/Resource/V2Constants.php',
+	'Obs\Internal\Resource\V2RequestResource' => __DIR__.'/Obs/Internal/Resource/V2RequestResource.php',
+	'Obs\Internal\SendRequestTrait' => __DIR__.'/Obs/Internal/SendRequestTrait.php',
+	'Obs\Internal\Signature\AbstractSignature' => __DIR__.'/Obs/Internal/Signature/AbstractSignature.php',
+	'Obs\Internal\Signature\DefaultSignature' => __DIR__.'/Obs/Internal/Signature/DefaultSignature.php',
+	'Obs\Internal\Signature\SignatureInterface' => __DIR__.'/Obs/Internal/Signature/SignatureInterface.php',
+	'Obs\Internal\Signature\V4Signature' => __DIR__.'/Obs/Internal/Signature/V4Signature.php',
+	'Obs\Log\ObsConfig' => __DIR__.'/Obs/Log/ObsConfig.php',
+	'Obs\Log\ObsLog' => __DIR__.'/Obs/Log/ObsLog.php',
+	'Obs\ObsClient' => __DIR__.'/Obs/ObsClient.php',
+	'Obs\ObsException' => __DIR__.'/Obs/ObsException.php',
+];
+

+spl_autoload_register(function ($class) use ($mapping) {
+    if (isset($mapping[$class])) {
+        require $mapping[$class];
+    }
+}, true);

+ 30 - 0
app/Listeners/Command.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Listeners;
+
+use Illuminate\Console\Events\CommandFinished;
+
+class Command
+{
+    /**
+     * Create the event listener.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Handle the event.
+     *
+     * @param CommandFinished $event
+     * @return void
+     */
+    public function handle(CommandFinished $event)
+    {
+        //
+        // dd($event->command);
+    }
+}

+ 28 - 0
app/Listeners/RouteMatched.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Listeners;
+
+class RouteMatched
+{
+    /**
+     * Create the event listener.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Handle the event.
+     *
+     * @param  object  $event
+     * @return void
+     */
+    public function handle(\Illuminate\Routing\Events\RouteMatched $event)
+    {
+        //
+        // dd($event->route);
+    }
+}

+ 27 - 0
app/Listeners/test.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Listeners;
+
+class test
+{
+    /**
+     * Create the event listener.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Handle the event.
+     *
+     * @param  object  $event
+     * @return void
+     */
+    public function handle($event)
+    {
+        //
+    }
+}

+ 11 - 0
app/Models/Modules/Users/Models/CatchController.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models\Modules\Users\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class CatchController extends Model
+{
+    use HasFactory;
+}

+ 45 - 0
app/Models/User.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace App\Models;
+
+// use Illuminate\Contracts\Auth\MustVerifyEmail;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Foundation\Auth\User as Authenticatable;
+use Illuminate\Notifications\Notifiable;
+
+class User extends Authenticatable
+{
+    use HasFactory, Notifiable;
+
+    protected $table = 'users';
+
+    /**
+     * The attributes that are mass assignable.
+     *
+     * @var array<int, string>
+     */
+    protected $fillable = [
+        'name',
+        'email',
+        'password',
+    ];
+
+    /**
+     * The attributes that should be hidden for serialization.
+     *
+     * @var array<int, string>
+     */
+    protected $hidden = [
+        'password',
+        'remember_token',
+    ];
+
+    /**
+     * The attributes that should be cast.
+     *
+     * @var array<string, string>
+     */
+    protected $casts = [
+        'email_verified_at' => 'datetime',
+    ];
+}

+ 28 - 0
app/Providers/AppServiceProvider.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Support\ServiceProvider;
+
+class AppServiceProvider extends ServiceProvider
+{
+    /**
+     * Register any application services.
+     *
+     * @return void
+     */
+    public function register()
+    {
+        //
+    }
+
+    /**
+     * Bootstrap any application services.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        //
+    }
+}

+ 30 - 0
app/Providers/AuthServiceProvider.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Providers;
+
+// use Illuminate\Support\Facades\Gate;
+use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
+
+class AuthServiceProvider extends ServiceProvider
+{
+    /**
+     * The model to policy mappings for the application.
+     *
+     * @var array<class-string, class-string>
+     */
+    protected $policies = [
+        // 'App\Models\Model' => 'App\Policies\ModelPolicy',
+    ];
+
+    /**
+     * Register any authentication / authorization services.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        $this->registerPolicies();
+
+        //
+    }
+}

+ 21 - 0
app/Providers/BroadcastServiceProvider.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Support\Facades\Broadcast;
+use Illuminate\Support\ServiceProvider;
+
+class BroadcastServiceProvider extends ServiceProvider
+{
+    /**
+     * Bootstrap any application services.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        Broadcast::routes();
+
+        require base_path('routes/channels.php');
+    }
+}

+ 53 - 0
app/Providers/EventServiceProvider.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace App\Providers;
+
+use App\Listeners\Command;
+use Illuminate\Auth\Events\Registered;
+use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
+use Illuminate\Console\Events\CommandFinished;
+use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
+use Illuminate\Routing\Events\RouteMatched;
+use Illuminate\Support\Facades\Event;
+
+class EventServiceProvider extends ServiceProvider
+{
+    /**
+     * The event to listener mappings for the application.
+     *
+     * @var array<class-string, array<int, class-string>>
+     */
+    protected $listen = [
+        Registered::class => [
+            SendEmailVerificationNotification::class,
+        ],
+
+        RouteMatched::class => [
+            \App\Listeners\RouteMatched::class
+        ],
+
+        CommandFinished::class => [
+            Command::class
+        ]
+    ];
+
+    /**
+     * Register any events for your application.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        //
+    }
+
+    /**
+     * Determine if events and listeners should be automatically discovered.
+     *
+     * @return bool
+     */
+    public function shouldDiscoverEvents()
+    {
+        return false;
+    }
+}

+ 62 - 0
app/Providers/RouteServiceProvider.php

@@ -0,0 +1,62 @@
+<?php
+
+namespace App\Providers;
+
+use Catch\CatchAdmin;
+use Illuminate\Cache\RateLimiting\Limit;
+use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
+use Illuminate\Http\Request;
+use Illuminate\Routing\CompiledRouteCollection;
+use Illuminate\Support\Facades\RateLimiter;
+use Illuminate\Support\Facades\Route;
+
+class RouteServiceProvider extends ServiceProvider
+{
+    /**
+     * The path to the "home" route for your application.
+     *
+     * Typically, users are redirected here after authentication.
+     *
+     * @var string
+     */
+    public const HOME = '/home';
+
+    /**
+     * Define your route model bindings, pattern filters, and other route configuration.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        $this->configureRateLimiting();
+
+        $this->routes(function () {
+            Route::middleware('api')
+                ->prefix('api')
+                ->group(base_path('routes/api.php'));
+
+            Route::middleware('web')
+                ->group(base_path('routes/web.php'));
+        });
+
+        $this->booted(function(){
+            $this->app->booted(function (){
+                if (file_exists('loadCachedAdminRoutes')) {
+                    loadCachedAdminRoutes();
+                }
+            });
+        });
+    }
+
+    /**
+     * Configure the rate limiters for the application.
+     *
+     * @return void
+     */
+    protected function configureRateLimiting()
+    {
+        RateLimiter::for('api', function (Request $request) {
+            return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
+        });
+    }
+}

+ 53 - 0
artisan

@@ -0,0 +1,53 @@
+#!/usr/bin/env php
+<?php
+
+define('LARAVEL_START', microtime(true));
+
+/*
+|--------------------------------------------------------------------------
+| Register The Auto Loader
+|--------------------------------------------------------------------------
+|
+| Composer provides a convenient, automatically generated class loader
+| for our application. We just need to utilize it! We'll require it
+| into the script here so that we do not have to worry about the
+| loading of any of our classes manually. It's great to relax.
+|
+*/
+
+require __DIR__.'/vendor/autoload.php';
+
+$app = require_once __DIR__.'/bootstrap/app.php';
+
+/*
+|--------------------------------------------------------------------------
+| Run The Artisan Application
+|--------------------------------------------------------------------------
+|
+| When we run the console application, the current CLI command will be
+| executed in this console and the response sent back to a terminal
+| or another output device for the developers. Here goes nothing!
+|
+*/
+
+$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
+
+$status = $kernel->handle(
+    $input = new Symfony\Component\Console\Input\ArgvInput,
+    new Symfony\Component\Console\Output\ConsoleOutput
+);
+
+/*
+|--------------------------------------------------------------------------
+| Shutdown The Application
+|--------------------------------------------------------------------------
+|
+| Once Artisan has finished running, we will fire off the shutdown events
+| so that any final work may be done by the application before we shut
+| down the process. This is the last thing to happen to the request.
+|
+*/
+
+$kernel->terminate($input, $status);
+
+exit($status);

+ 1 - 0
blaze/config/blaze.php

@@ -0,0 +1 @@
+<?php

+ 3 - 0
blaze/resources/views/components/navigate.blade.php

@@ -0,0 +1,3 @@
+<div>
+    Hello Navigate
+</div>

+ 1 - 0
blaze/resources/views/components/paginate.blade.php

@@ -0,0 +1 @@
+<?php

+ 1 - 0
blaze/src/BlazeServiceProvider.php

@@ -0,0 +1 @@
+<?php

+ 1 - 0
blaze/src/Components/Navigate.php

@@ -0,0 +1 @@
+<?php

+ 1 - 0
blaze/src/Components/Paginate.php

@@ -0,0 +1 @@
+<?php

+ 8 - 0
blaze/src/Contracts/DirectiveContract.php

@@ -0,0 +1,8 @@
+<?php
+
+namespace Blaze\Contracts;
+
+interface DirectiveContract
+{
+    
+}

+ 0 - 0
blaze/src/Directives/Post.php


Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott