1.0
This commit is contained in:
602
Plugin.php
Normal file
602
Plugin.php
Normal file
File diff suppressed because it is too large
Load Diff
5
composer.json
Normal file
5
composer.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"require": {
|
||||||
|
"qiniu/php-sdk": "^7.14"
|
||||||
|
}
|
||||||
|
}
|
||||||
142
composer.lock
generated
Normal file
142
composer.lock
generated
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "e53b7aa650906cf4c75020ac18b97155",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "myclabs/php-enum",
|
||||||
|
"version": "1.8.5",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/myclabs/php-enum.git",
|
||||||
|
"reference": "e7be26966b7398204a234f8673fdad5ac6277802"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/e7be26966b7398204a234f8673fdad5ac6277802",
|
||||||
|
"reference": "e7be26966b7398204a234f8673fdad5ac6277802",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"php": "^7.3 || ^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^9.5",
|
||||||
|
"squizlabs/php_codesniffer": "1.*",
|
||||||
|
"vimeo/psalm": "^4.6.2 || ^5.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"MyCLabs\\Enum\\": "src/"
|
||||||
|
},
|
||||||
|
"classmap": [
|
||||||
|
"stubs/Stringable.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP Enum contributors",
|
||||||
|
"homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP Enum implementation",
|
||||||
|
"homepage": "https://github.com/myclabs/php-enum",
|
||||||
|
"keywords": [
|
||||||
|
"enum"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/myclabs/php-enum/issues",
|
||||||
|
"source": "https://github.com/myclabs/php-enum/tree/1.8.5"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/mnapoli",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-01-14T11:49:03+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "qiniu/php-sdk",
|
||||||
|
"version": "v7.14.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/qiniu/php-sdk.git",
|
||||||
|
"reference": "ee752ffa7263ce99fca0bd7340cf13c486a3516c"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/qiniu/php-sdk/zipball/ee752ffa7263ce99fca0bd7340cf13c486a3516c",
|
||||||
|
"reference": "ee752ffa7263ce99fca0bd7340cf13c486a3516c",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-curl": "*",
|
||||||
|
"ext-xml": "*",
|
||||||
|
"myclabs/php-enum": "~1.5.2 || ~1.6.6 || ~1.7.7 || ~1.8.4",
|
||||||
|
"php": ">=5.3.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"paragonie/random_compat": ">=2",
|
||||||
|
"phpunit/phpunit": "^4.8 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4",
|
||||||
|
"squizlabs/php_codesniffer": "^2.3 || ~3.6"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/Qiniu/functions.php",
|
||||||
|
"src/Qiniu/Http/Middleware/Middleware.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Qiniu\\": "src/Qiniu"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Qiniu",
|
||||||
|
"email": "sdk@qiniu.com",
|
||||||
|
"homepage": "http://www.qiniu.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Qiniu Resource (Cloud) Storage SDK for PHP",
|
||||||
|
"homepage": "http://developer.qiniu.com/",
|
||||||
|
"keywords": [
|
||||||
|
"cloud",
|
||||||
|
"qiniu",
|
||||||
|
"sdk",
|
||||||
|
"storage"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/qiniu/php-sdk/issues",
|
||||||
|
"source": "https://github.com/qiniu/php-sdk/tree/v7.14.0"
|
||||||
|
},
|
||||||
|
"time": "2024-10-25T08:39:01+00:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": [],
|
||||||
|
"platform-dev": [],
|
||||||
|
"plugin-api-version": "2.0.0"
|
||||||
|
}
|
||||||
71
php-sdk/.github/workflows/test-ci.yml
vendored
Normal file
71
php-sdk/.github/workflows/test-ci.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
name: PHP CI with Composer
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup php for mock server
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.2'
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: '1.21.x'
|
||||||
|
|
||||||
|
- name: Setup build-in server
|
||||||
|
run: |
|
||||||
|
nohup php -S localhost:9000 -t ./tests/mock-server/ > phpd.log 2>&1 &
|
||||||
|
echo $! > mock-server.pid
|
||||||
|
|
||||||
|
cd tests/socks5-server/
|
||||||
|
nohup go run main.go > ../../socks5.log 2>&1 &
|
||||||
|
echo $! > ../../socks-server.pid
|
||||||
|
|
||||||
|
- name: Setup php
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
composer self-update
|
||||||
|
composer install --no-interaction --prefer-source --dev
|
||||||
|
|
||||||
|
- name: Run cases
|
||||||
|
run: |
|
||||||
|
./vendor/bin/phpcs --standard=PSR2 src
|
||||||
|
./vendor/bin/phpcs --standard=PSR2 examples
|
||||||
|
./vendor/bin/phpcs --standard=PSR2 tests
|
||||||
|
./vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||||
|
cat mock-server.pid | xargs kill
|
||||||
|
cat socks-server.pid | xargs kill
|
||||||
|
|
||||||
|
env:
|
||||||
|
QINIU_ACCESS_KEY: ${{ secrets.QINIU_ACCESS_KEY }}
|
||||||
|
QINIU_SECRET_KEY: ${{ secrets.QINIU_SECRET_KEY }}
|
||||||
|
QINIU_TEST_BUCKET: ${{ secrets.QINIU_TEST_BUCKET }}
|
||||||
|
QINIU_TEST_DOMAIN: ${{ secrets.QINIU_TEST_DOMAIN }}
|
||||||
|
|
||||||
|
- name: Print mock server log
|
||||||
|
if: ${{ failure() }}
|
||||||
|
run: |
|
||||||
|
cat phpd.log
|
||||||
|
|
||||||
|
- name: Print socks5 server log
|
||||||
|
if: ${{ failure() }}
|
||||||
|
run: |
|
||||||
|
cat socks5.log
|
||||||
|
|
||||||
|
- name: After_success
|
||||||
|
run: bash <(curl -s https://codecov.io/bash)
|
||||||
19
php-sdk/.github/workflows/version-check.yml
vendored
Normal file
19
php-sdk/.github/workflows/version-check.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: PHP SDK Version Check
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v[0-9]+.[0-9]+.[0-9]+"
|
||||||
|
jobs:
|
||||||
|
linux:
|
||||||
|
name: Version Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set env
|
||||||
|
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
|
||||||
|
- name: Check
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
grep -qF "## ${RELEASE_VERSION}" CHANGELOG.md
|
||||||
|
grep -qF "const SDK_VER = '${RELEASE_VERSION}';" src/Qiniu/Config.php
|
||||||
12
php-sdk/.gitignore
vendored
Normal file
12
php-sdk/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
*.phar
|
||||||
|
*.zip
|
||||||
|
build/artifacts
|
||||||
|
phpunit.xml
|
||||||
|
phpunit.functional.xml
|
||||||
|
.DS_Store
|
||||||
|
.swp
|
||||||
|
.build
|
||||||
|
composer.lock
|
||||||
|
vendor
|
||||||
|
src/package.xml
|
||||||
|
.idea/
|
||||||
42
php-sdk/.scrutinizer.yml
Normal file
42
php-sdk/.scrutinizer.yml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
filter:
|
||||||
|
excluded_paths: [tests/*]
|
||||||
|
checks:
|
||||||
|
php:
|
||||||
|
code_rating: true
|
||||||
|
remove_extra_empty_lines: true
|
||||||
|
remove_php_closing_tag: true
|
||||||
|
remove_trailing_whitespace: true
|
||||||
|
fix_use_statements:
|
||||||
|
remove_unused: true
|
||||||
|
preserve_multiple: false
|
||||||
|
preserve_blanklines: true
|
||||||
|
order_alphabetically: true
|
||||||
|
fix_php_opening_tag: true
|
||||||
|
fix_linefeed: true
|
||||||
|
fix_line_ending: true
|
||||||
|
fix_identation_4spaces: true
|
||||||
|
fix_doc_comments: true
|
||||||
|
tools:
|
||||||
|
external_code_coverage:
|
||||||
|
timeout: 1200
|
||||||
|
runs: 3
|
||||||
|
php_analyzer: true
|
||||||
|
php_code_coverage: false
|
||||||
|
php_code_sniffer:
|
||||||
|
config:
|
||||||
|
standard: PSR2
|
||||||
|
filter:
|
||||||
|
paths: ['src']
|
||||||
|
php_loc:
|
||||||
|
enabled: true
|
||||||
|
excluded_dirs: [vendor, tests]
|
||||||
|
php_cpd:
|
||||||
|
enabled: true
|
||||||
|
excluded_dirs: [vendor, tests]
|
||||||
|
build:
|
||||||
|
nodes:
|
||||||
|
analysis:
|
||||||
|
tests:
|
||||||
|
override:
|
||||||
|
- php-scrutinizer-run
|
||||||
|
|
||||||
196
php-sdk/CHANGELOG.md
Normal file
196
php-sdk/CHANGELOG.md
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 7.14.0 (2024-10-16)
|
||||||
|
* 对象存储,持久化处理支持工作流模版
|
||||||
|
|
||||||
|
## 7.13.0 (2024-09-05)
|
||||||
|
* 对象存储,验证回调方法新增支持 Qiniu 签名
|
||||||
|
* 对象存储,调整查询空间区域域名顺序与默认空间管理域名
|
||||||
|
* 支持闲时任务配置
|
||||||
|
|
||||||
|
## 7.12.1 (2024-02-21)
|
||||||
|
* 对象存储,添加上传策略部分字段
|
||||||
|
|
||||||
|
## 7.12.0 (2023-12-11)
|
||||||
|
* 对象存储,支持归档直读存储
|
||||||
|
* 对象存储,批量操作支持自动查询 rs 服务域名
|
||||||
|
|
||||||
|
## 7.11.0 (2023-09-05)
|
||||||
|
* 支持代理
|
||||||
|
|
||||||
|
## 7.10.1 (2023-08-04)
|
||||||
|
* 修复部分 API 调用中间件合并失败(#417)
|
||||||
|
|
||||||
|
## 7.10.0 (2023-06-20)
|
||||||
|
* 对象存储,新增请求中间件逻辑,方便拓展请求逻辑
|
||||||
|
* 对象存储,新增备用 UC 域名用于查询区域域名
|
||||||
|
* 对象存储,修复分片上传初始化失败无法快速失败
|
||||||
|
* 对象存储,移除首尔区域
|
||||||
|
|
||||||
|
## 7.9.0 (2023-03-31)
|
||||||
|
* 对象存储,修复无法对 key 为空字符串的对象进行操作
|
||||||
|
* 修复 301 重定向无法正确获取 header 信息
|
||||||
|
* 对象存储,新增查询区域域名过期时间
|
||||||
|
* 对象存储,更新获取区域域名的接口
|
||||||
|
* 对象存储,更新查询 bucket 域名为 uc 服务
|
||||||
|
* 对象存储,新增 uc 服务可配置
|
||||||
|
|
||||||
|
## 7.8.0 (2022-10-25)
|
||||||
|
* 移除不推荐域名,并增加区域亚太-首尔和华东-浙江2
|
||||||
|
* 对象存储,修复断点上传的文件内容不正确
|
||||||
|
* 对象存储,优化分片上传 ctx 超时检测
|
||||||
|
|
||||||
|
## 7.7.0 (2022-09-02)
|
||||||
|
* 对象存储,新增支持设置文件级别生命周期 setObjectLifecycle API
|
||||||
|
* 对象存储,内置增加七牛新建存储区域域名信息
|
||||||
|
* 修复当前已知问题
|
||||||
|
|
||||||
|
## 7.6.0 (2022-06-08)
|
||||||
|
* 对象存储,管理类 API 发送请求时增加 [X-Qiniu-Date](https://developer.qiniu.com/kodo/3924/common-request-headers) (生成请求的时间) header
|
||||||
|
|
||||||
|
|
||||||
|
## 7.5.0 (2022-04-18)
|
||||||
|
* 对象存储,新增支持 [深度归档存储类型](https://developer.qiniu.com/kodo/3956/kodo-category#deep_archive)
|
||||||
|
|
||||||
|
## 7.4.3 (2022-04-01)
|
||||||
|
* 优化签名算法逻辑
|
||||||
|
|
||||||
|
## 7.4.2(2022-03-01)
|
||||||
|
* 修复已知关于请求 Header 处理不当问题,比如没有处理为大小写不敏感等问题
|
||||||
|
|
||||||
|
## 7.4.1(2021-09-24)
|
||||||
|
* 修复了 分片上传 v2 已知问题,明确给出了参数不合理情况下对应的错误提示信息
|
||||||
|
|
||||||
|
## 7.4.0 (2021-07-19)
|
||||||
|
* 【对象存储】支持 [分片上传 v2](https://developer.qiniu.com/kodo/7458/multipartupload) 和 断点续传,使用方式见 [开发者文档](https://developer.qiniu.com/kodo/1241/php#resume-upload-file)
|
||||||
|
|
||||||
|
## 7.3.0 (2020-09-24)
|
||||||
|
### 新增
|
||||||
|
* 【对象存储】增加异步抓取方法与demo
|
||||||
|
* 【融合cdn】增加查询CDN刷新记录、查询CDN预取记录方法与demo
|
||||||
|
* 【云短信】增加查询短信发送记录的方法
|
||||||
|
* 【实时音视频】增加rtc停止房间的合流转推方法
|
||||||
|
* 【内容审核】增加图片审核、视频审核方法与demo
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
* 【对象存储】修复签算 token 时上传策略中的 forceSaveKey 字段不生效的问题
|
||||||
|
* 【对象存储】修复更新空间事件通知规则方法
|
||||||
|
|
||||||
|
### 优化
|
||||||
|
* 【对象存储】创建空间迁移到mkbucketv3 api
|
||||||
|
* 优化对 http2 返回头的判断
|
||||||
|
* 优化 demo 中的文档注释说明
|
||||||
|
* docs 目录下的 rtc demo 移动至 examples/rtc 目录下
|
||||||
|
* docs 目录下的 sms demo 移动至 examples/sms 目录下
|
||||||
|
|
||||||
|
## 7.2.10 (2019-10-28)
|
||||||
|
* 去除云短信类类型指定
|
||||||
|
* 修改不传文件名时存在表单上传错误的情况
|
||||||
|
|
||||||
|
## 7.2.9 (2019-07-09)
|
||||||
|
* 添加空间管理、云短信接口
|
||||||
|
* 去除无效参数
|
||||||
|
|
||||||
|
## 7.2.7 (2018-11-06)
|
||||||
|
* 添加 QVM 内网上传到 KODO 的 zone 设置
|
||||||
|
|
||||||
|
## 7.2.6 (2018-05-18)
|
||||||
|
* 修复rs,rsf在不同机房默认的https域名
|
||||||
|
|
||||||
|
## 7.2.5 (2018-05-10)
|
||||||
|
* 修复表单上传中多余的参数checkCrc导致的fname错位问题
|
||||||
|
|
||||||
|
## 7.2.4 (2018-05-09)
|
||||||
|
### 增加
|
||||||
|
* 连麦功能
|
||||||
|
|
||||||
|
## 7.2.3 (2018-01-20)
|
||||||
|
### 增加
|
||||||
|
* 新加坡机房
|
||||||
|
### 修正
|
||||||
|
* 获取域名的入口域名
|
||||||
|
* http回复头部兼容大小写
|
||||||
|
|
||||||
|
## 7.2.2 (2017-11-06)
|
||||||
|
### 增加
|
||||||
|
* Qiniu算法的鉴权方法
|
||||||
|
|
||||||
|
## 7.1.4 (2017-06-21)
|
||||||
|
### 增加
|
||||||
|
* cdn 文件/目录 刷新
|
||||||
|
* cdn 获取 流量/带宽
|
||||||
|
* cdn 获取域名的访问日志列表
|
||||||
|
* cdn 对资源链接进行时间戳防盗链签名
|
||||||
|
|
||||||
|
## 7.1.3 (2016-11-18)
|
||||||
|
### 增加
|
||||||
|
* move, copy操作增加force参数
|
||||||
|
|
||||||
|
## 7.1.2 (2016-11-12)
|
||||||
|
### 修正
|
||||||
|
* 明确抛出获取各区域域名失败时的报错
|
||||||
|
|
||||||
|
## 7.1.1 (2016-11-02)
|
||||||
|
### 修正
|
||||||
|
* 多区域配置文件存储目录从home修改到tmp目录
|
||||||
|
|
||||||
|
|
||||||
|
## 7.1.0 (2016-10-22)
|
||||||
|
### 增加
|
||||||
|
* 多存储区域的支持
|
||||||
|
|
||||||
|
## 7.0.8 (2016-07-19)
|
||||||
|
### 增加
|
||||||
|
* demo
|
||||||
|
* https url 支持
|
||||||
|
* deleteAfterDays 策略
|
||||||
|
* 添加图片处理链接统一拼接方法 by @SherlockRen
|
||||||
|
|
||||||
|
## 7.0.7 (2016-01-12)
|
||||||
|
### 修正
|
||||||
|
* PersistentFop参数pipeline和notify_url失效
|
||||||
|
* resume 模式 close file inputstream
|
||||||
|
|
||||||
|
## 7.0.6 (2015-12-05)
|
||||||
|
### 修正
|
||||||
|
* php7.0 Json 对空字符串解析单元测试报错
|
||||||
|
* 开启安全模式或者设置可操作目录树时,设置CURLOPT_FOLLOWLOCATION报错, by @twocabbages
|
||||||
|
* fetch 支持不指定key, by @sinkcup
|
||||||
|
|
||||||
|
## 7.0.5 (2015-10-29)
|
||||||
|
### 增加
|
||||||
|
* 增加上传策略最小文件大小限制 fsizeMin
|
||||||
|
* 增加常见examples
|
||||||
|
|
||||||
|
## 7.0.4 (2015-07-23)
|
||||||
|
### 修正
|
||||||
|
* 一些地方的严格比较检查
|
||||||
|
* resumeupload 备用地址失效
|
||||||
|
|
||||||
|
## 7.0.3 (2015-07-10)
|
||||||
|
### 修改
|
||||||
|
* 多zone 支持
|
||||||
|
|
||||||
|
## 7.0.2 (2015-04-18)
|
||||||
|
### 修改
|
||||||
|
* fetch 接口返回内容调整
|
||||||
|
* pfop 接口调整
|
||||||
|
|
||||||
|
###修正
|
||||||
|
* exception 类调用
|
||||||
|
|
||||||
|
## 7.0.1 (2015-03-27)
|
||||||
|
### 增加
|
||||||
|
* 增加代码注释
|
||||||
|
|
||||||
|
## 7.0.0 (2015-02-03)
|
||||||
|
|
||||||
|
### 增加
|
||||||
|
* 简化上传接口
|
||||||
|
* 自动选择断点续上传还是直传
|
||||||
|
* 重构代码,接口和内部结构更清晰
|
||||||
|
* 改变mime
|
||||||
|
* 代码覆盖度报告
|
||||||
|
* policy改为array, 便于灵活增加,并加入过期字段检查
|
||||||
|
* 文件列表支持目录形式
|
||||||
|
* 利用元编程方式支持 fop 和 pfop
|
||||||
30
php-sdk/CONTRIBUTING.md
Normal file
30
php-sdk/CONTRIBUTING.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# 贡献代码指南
|
||||||
|
|
||||||
|
我们非常欢迎大家来贡献代码,我们会向贡献者致以最诚挚的敬意。
|
||||||
|
|
||||||
|
一般可以通过在Github上提交[Pull Request](https://github.com/qiniu/php-sdk)来贡献代码。
|
||||||
|
|
||||||
|
## Pull Request要求
|
||||||
|
|
||||||
|
- **[PSR-2 编码风格标准](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** 。要通过项目中的code sniffer检查。
|
||||||
|
|
||||||
|
- **代码格式** 提交前 请按 ./vendor/bin/phpcbf --standard=PSR2 进行格式化。
|
||||||
|
|
||||||
|
- **必须添加测试!** - 如果没有测试(单元测试、集成测试都可以),那么提交的补丁是不会通过的。
|
||||||
|
|
||||||
|
- **记得更新文档** - 保证`README.md`以及其他相关文档及时更新,和代码的变更保持一致性。
|
||||||
|
|
||||||
|
- **考虑我们的发布周期** - 我们的版本号会服从[SemVer v2.0.0](http://semver.org/),我们绝对不会随意变更对外的API。
|
||||||
|
|
||||||
|
- **创建feature分支** - 最好不要从你的master分支提交 pull request。
|
||||||
|
|
||||||
|
- **一个feature提交一个pull请求** - 如果你的代码变更了多个操作,那就提交多个pull请求吧。
|
||||||
|
|
||||||
|
- **清晰的commit历史** - 保证你的pull请求的每次commit操作都是有意义的。如果你开发中需要执行多次的即时commit操作,那么请把它们放到一起再提交pull请求。
|
||||||
|
|
||||||
|
## 运行测试
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
./vendor/bin/phpunit tests/Qiniu/Tests/
|
||||||
|
|
||||||
|
```
|
||||||
22
php-sdk/LICENSE
Normal file
22
php-sdk/LICENSE
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Qiniu, Ltd.<sdk@qiniu.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.
|
||||||
|
|
||||||
76
php-sdk/README.md
Normal file
76
php-sdk/README.md
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# Qiniu Cloud SDK for PHP
|
||||||
|
[](LICENSE)
|
||||||
|
[](https://travis-ci.org/qiniu/php-sdk)
|
||||||
|
[](https://github.com/qiniu/php-sdk/releases)
|
||||||
|
[](https://packagist.org/packages/qiniu/php-sdk)
|
||||||
|
[](https://packagist.org/packages/qiniu/php-sdk)
|
||||||
|
[](https://scrutinizer-ci.com/g/qiniu/php-sdk/?branch=master)
|
||||||
|
[](https://codecov.io/gh/qiniu/php-sdk)
|
||||||
|
[](https://gitter.im/qiniu/php-sdk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
[](http://weibo.com/qiniutek)
|
||||||
|
|
||||||
|
|
||||||
|
## 安装
|
||||||
|
|
||||||
|
推荐使用 `composer` 进行安装。可以使用 composer.json 声明依赖,或者运行下面的命令。SDK 包已经放到这里 [`qiniu/php-sdk`][install-packagist] 。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ composer require qiniu/php-sdk
|
||||||
|
```
|
||||||
|
|
||||||
|
## 运行环境
|
||||||
|
|
||||||
|
| Qiniu SDK版本 | PHP 版本 |
|
||||||
|
|:--------------------:|:-----------------------------------------------:|
|
||||||
|
| 7.x | cURL extension, 5.3 - 5.6, 7.0 - 7.4, 8.0-8.1 |
|
||||||
|
| 6.x | cURL extension, 5.2 - 5.6 |
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
|
||||||
|
### 上传
|
||||||
|
```php
|
||||||
|
use Qiniu\Storage\UploadManager;
|
||||||
|
use Qiniu\Auth;
|
||||||
|
...
|
||||||
|
$uploadMgr = new UploadManager();
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$token = $auth->uploadToken($bucket);
|
||||||
|
list($ret, $error) = $uploadMgr->putFile($token, 'key', 'filePath');
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
## 测试
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
$ ./vendor/bin/phpunit tests/Qiniu/Tests/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
- `$error` 保留了请求响应的信息,失败情况下 `ret` 为 `none`, 将 `$error` 可以打印出来,提交给我们。
|
||||||
|
- API 的使用 demo 可以参考 [examples](https://github.com/qiniu/php-sdk/tree/master/examples)。
|
||||||
|
|
||||||
|
## 代码贡献
|
||||||
|
|
||||||
|
详情参考[代码提交指南](https://github.com/qiniu/php-sdk/blob/master/CONTRIBUTING.md)。
|
||||||
|
|
||||||
|
## 贡献记录
|
||||||
|
|
||||||
|
- [所有贡献者](https://github.com/qiniu/php-sdk/contributors)
|
||||||
|
|
||||||
|
## 联系我们
|
||||||
|
|
||||||
|
- 如果需要帮助,请提交工单(在portal右侧点击咨询和建议提交工单,或者直接向 support@qiniu.com 发送邮件)
|
||||||
|
- 如果有什么问题,可以到问答社区提问,[问答社区](https://qiniu.segmentfault.com/)
|
||||||
|
- 更详细的文档,见[官方文档站](https://developer.qiniu.com/)
|
||||||
|
- 如果发现了 bug, 欢迎提交 [issue](https://github.com/qiniu/php-sdk/issues)
|
||||||
|
- 如果有功能需求,欢迎提交 [issue](https://github.com/qiniu/php-sdk/issues)
|
||||||
|
- 如果要提交代码,欢迎提交 pull request
|
||||||
|
- 欢迎关注我们的[微信](https://www.qiniu.com/#weixin) [微博](https://weibo.com/qiniutek),及时获取动态信息。
|
||||||
|
|
||||||
|
## 代码许可
|
||||||
|
|
||||||
|
The MIT License (MIT).详情见 [License文件](https://github.com/qiniu/php-sdk/blob/master/LICENSE).
|
||||||
|
|
||||||
|
[packagist]: http://packagist.org
|
||||||
|
[install-packagist]: https://packagist.org/packages/qiniu/php-sdk
|
||||||
19
php-sdk/autoload.php
Normal file
19
php-sdk/autoload.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( file_exists(dirname(__FILE__).'/vendor/autoload.php') ) {
|
||||||
|
require_once dirname(__FILE__).'/vendor/autoload.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
function classLoader($class)
|
||||||
|
{
|
||||||
|
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
|
||||||
|
$file = __DIR__ . '/src/' . $path . '.php';
|
||||||
|
|
||||||
|
if (file_exists($file)) {
|
||||||
|
require_once $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spl_autoload_register('classLoader');
|
||||||
|
|
||||||
|
require_once __DIR__ . '/src/Qiniu/functions.php';
|
||||||
|
require_once __DIR__ . '/src/Qiniu/Http/Middleware/Middleware.php';
|
||||||
28
php-sdk/codecov.yml
Normal file
28
php-sdk/codecov.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
codecov:
|
||||||
|
ci:
|
||||||
|
- prow.qiniu.io # prow 里面运行需添加,其他 CI 不要
|
||||||
|
require_ci_to_pass: no # 改为 no,否则 codecov 会等待其他 GitHub 上所有 CI 通过才会留言。
|
||||||
|
|
||||||
|
github_checks: #关闭github checks
|
||||||
|
annotations: false
|
||||||
|
|
||||||
|
comment:
|
||||||
|
layout: "reach, diff, flags, files"
|
||||||
|
behavior: new # 默认是更新旧留言,改为 new,删除旧的,增加新的。
|
||||||
|
require_changes: false # if true: only post the comment if coverage changes
|
||||||
|
require_base: no # [yes :: must have a base report to post]
|
||||||
|
require_head: yes # [yes :: must have a head report to post]
|
||||||
|
branches: # branch names that can post comment
|
||||||
|
- "master"
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
status: # 评判 pr 通过的标准
|
||||||
|
patch: off
|
||||||
|
project: # project 统计所有代码x
|
||||||
|
default:
|
||||||
|
# basic
|
||||||
|
target: 85% # 总体通过标准
|
||||||
|
threshold: 3% # 允许单次下降的幅度
|
||||||
|
base: auto
|
||||||
|
if_not_found: success
|
||||||
|
if_ci_failed: error
|
||||||
40
php-sdk/composer.json
Normal file
40
php-sdk/composer.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "qiniu/php-sdk",
|
||||||
|
"type": "library",
|
||||||
|
"description": "Qiniu Resource (Cloud) Storage SDK for PHP",
|
||||||
|
"keywords": [
|
||||||
|
"qiniu",
|
||||||
|
"storage",
|
||||||
|
"sdk",
|
||||||
|
"cloud"
|
||||||
|
],
|
||||||
|
"homepage": "http://developer.qiniu.com/",
|
||||||
|
"license": "MIT",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Qiniu",
|
||||||
|
"email": "sdk@qiniu.com",
|
||||||
|
"homepage": "http://www.qiniu.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.3",
|
||||||
|
"ext-xml": "*",
|
||||||
|
"ext-curl": "*",
|
||||||
|
"myclabs/php-enum": "~1.5.2 || ~1.6.6 || ~1.7.7 || ~1.8.4"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"paragonie/random_compat": ">=2",
|
||||||
|
"phpunit/phpunit": "^4.8 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4",
|
||||||
|
"squizlabs/php_codesniffer": "^2.3 || ~3.6"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Qiniu\\": "src/Qiniu"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/Qiniu/functions.php",
|
||||||
|
"src/Qiniu/Http/Middleware/Middleware.php"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
10
php-sdk/examples/README.md
Normal file
10
php-sdk/examples/README.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# examples
|
||||||
|
|
||||||
|
这些 examples 旨在帮助你快速了解使用七牛的 SDK。这些 demo 都是可以直接运行的, 但是在运行之前需要填上您自己的参数。
|
||||||
|
|
||||||
|
比如:
|
||||||
|
|
||||||
|
* `$bucket` 需要填上您想操作的 [bucket名字](https://portal.qiniu.com/kodo/bucket)。
|
||||||
|
* `$accessKey` 和 `$secretKey` 可以在我们的[管理后台](https://portal.qiniu.com/user/key)找到。
|
||||||
|
* 在进行`视频转码`, `压缩文件`等异步操作时 需要使用到的队列名称也可以在我们[管理后台](https://portal.qiniu.com/dora/media-gate/pipeline)新建。
|
||||||
|
|
||||||
42
php-sdk/examples/bucket_lifecycleRule.php
Normal file
42
php-sdk/examples/bucket_lifecycleRule.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Config;
|
||||||
|
use Qiniu\Storage\BucketManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$config = new Config();
|
||||||
|
$bucketManager = new BucketManager($auth, $config);
|
||||||
|
|
||||||
|
// 存储空间 - 新增生命周期规则
|
||||||
|
// 参考文档:https://developer.qiniu.com/kodo/manual/3699/life-cycle-management
|
||||||
|
|
||||||
|
$bucket = 'xxxx'; // 存储空间名称
|
||||||
|
$name = 'demo'; // 生命周期规则名称
|
||||||
|
$prefix = 'test'; // 规则策略中的前缀
|
||||||
|
$delete_after_days = 80; // 用户新创建的文件将在该设定时间之后自动删除
|
||||||
|
$to_line_after_days = 70; // 用户新创建的文件将在该设定的时间之后自动转为低频存储
|
||||||
|
$to_archive_ir_after_days = 71; // 用户新创建的文件将在该设定的时间之后自动转为归档直读存储
|
||||||
|
$to_archive_after_days = 72; // 用户新创建的文件将在该设定的时间之后自动转为归档存储
|
||||||
|
$to_deep_archive_after_days = 74; // 用户新创建的文件将在该设定的时间之后自动转为深度归档存储
|
||||||
|
|
||||||
|
list($ret, $err) = $bucketManager->bucketLifecycleRule(
|
||||||
|
$bucket,
|
||||||
|
$name,
|
||||||
|
$prefix,
|
||||||
|
$delete_after_days,
|
||||||
|
$to_line_after_days,
|
||||||
|
$to_archive_after_days,
|
||||||
|
$to_deep_archive_after_days,
|
||||||
|
$to_archive_ir_after_days
|
||||||
|
);
|
||||||
|
if ($err != null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
41
php-sdk/examples/cdn_get_bandwidth.php
Normal file
41
php-sdk/examples/cdn_get_bandwidth.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Cdn\CdnManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$cdnManager = new CdnManager($auth);
|
||||||
|
|
||||||
|
// 获取流量和带宽数据
|
||||||
|
// 参考文档:https://developer.qiniu.com/fusion/api/1230/traffic-bandwidth
|
||||||
|
|
||||||
|
$domains = array(
|
||||||
|
"javasdk.qiniudn.com",
|
||||||
|
"phpsdk.qiniudn.com"
|
||||||
|
);
|
||||||
|
|
||||||
|
$startDate = "2020-08-03";
|
||||||
|
$endDate = "2020-08-05";
|
||||||
|
|
||||||
|
// 5min or hour or day
|
||||||
|
$granularity = "day";
|
||||||
|
|
||||||
|
list($bandwidthData, $getBandwidthErr) = $cdnManager->getBandwidthData(
|
||||||
|
$domains,
|
||||||
|
$startDate,
|
||||||
|
$endDate,
|
||||||
|
$granularity
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($getBandwidthErr != null) {
|
||||||
|
var_dump($getBandwidthErr);
|
||||||
|
} else {
|
||||||
|
echo "get bandwidth data success\n";
|
||||||
|
print_r($bandwidthData);
|
||||||
|
}
|
||||||
35
php-sdk/examples/cdn_get_flux.php
Normal file
35
php-sdk/examples/cdn_get_flux.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use \Qiniu\Cdn\CdnManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$cdnManager = new CdnManager($auth);
|
||||||
|
|
||||||
|
// 获取流量和带宽数据
|
||||||
|
// 参考文档:https://developer.qiniu.com/fusion/api/1230/traffic-bandwidth
|
||||||
|
|
||||||
|
$domains = array(
|
||||||
|
"javasdk.qiniudn.com",
|
||||||
|
"phpsdk.qiniudn.com"
|
||||||
|
);
|
||||||
|
|
||||||
|
$startDate = "2020-08-03";
|
||||||
|
$endDate = "2020-08-05";
|
||||||
|
|
||||||
|
//5min or hour or day
|
||||||
|
$granularity = "day";
|
||||||
|
|
||||||
|
list($fluxData, $getFluxErr) = $cdnManager->getFluxData($domains, $startDate, $endDate, $granularity);
|
||||||
|
if ($getFluxErr != null) {
|
||||||
|
var_dump($getFluxErr);
|
||||||
|
} else {
|
||||||
|
echo "get flux data success\n";
|
||||||
|
print_r($fluxData);
|
||||||
|
}
|
||||||
31
php-sdk/examples/cdn_get_log_list.php
Normal file
31
php-sdk/examples/cdn_get_log_list.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Cdn\CdnManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$cdnManager = new CdnManager($auth);
|
||||||
|
|
||||||
|
// 获取日志下载链接
|
||||||
|
// 参考文档:https://developer.qiniu.com/fusion/api/1226/download-the-log
|
||||||
|
|
||||||
|
$domains = array(
|
||||||
|
"javasdk.qiniudn.com",
|
||||||
|
"phpsdk.qiniudn.com"
|
||||||
|
);
|
||||||
|
|
||||||
|
$logDate = '2020-08-05';
|
||||||
|
|
||||||
|
list($logListData, $getLogErr) = $cdnManager->getCdnLogList($domains, $logDate);
|
||||||
|
if ($getLogErr != null) {
|
||||||
|
var_dump($getLogErr);
|
||||||
|
} else {
|
||||||
|
echo "get cdn log list success\n";
|
||||||
|
print_r($logListData);
|
||||||
|
}
|
||||||
46
php-sdk/examples/cdn_get_prefetch_list.php
Normal file
46
php-sdk/examples/cdn_get_prefetch_list.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Cdn\CdnManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$cdnManager = new CdnManager($auth);
|
||||||
|
|
||||||
|
// 查询 CDN 预取记录
|
||||||
|
// 参考文档:https://developer.qiniu.com/fusion/api/1227/file-prefetching#4
|
||||||
|
|
||||||
|
$requestId = null; // 指定要查询记录所在的刷新请求id
|
||||||
|
|
||||||
|
// 要查询的url列表
|
||||||
|
$urls = array(
|
||||||
|
"http://sdk.peterpy.cn/sdktest.png",
|
||||||
|
"http://sdk.peterpy.cn/qiniulogo.png"
|
||||||
|
);
|
||||||
|
|
||||||
|
$state = 'success'; // 指定要查询记录的状态,取值 processing/success/failure
|
||||||
|
$pageNo = 0; // 要求返回的页号,默认为0
|
||||||
|
$pageSize = 100; // 要求返回的页长度,默认为100
|
||||||
|
$startTime = '2020-09-11 12:00:00'; // 指定查询的开始日期,格式2006-01-01
|
||||||
|
$endTime = '2020-09-20 21:00:00'; // 指定查询的结束日期,格式2006-01-01
|
||||||
|
|
||||||
|
list($ret, $err) = $cdnManager->getCdnPrefetchList(
|
||||||
|
$requestId,
|
||||||
|
$urls,
|
||||||
|
$state,
|
||||||
|
$pageNo,
|
||||||
|
$pageSize,
|
||||||
|
$startTime,
|
||||||
|
$endTime
|
||||||
|
);
|
||||||
|
echo "\n====> query prefetch list: \n";
|
||||||
|
if ($err !== null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
48
php-sdk/examples/cdn_get_refresh_list.php
Normal file
48
php-sdk/examples/cdn_get_refresh_list.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Cdn\CdnManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$cdnManager = new CdnManager($auth);
|
||||||
|
|
||||||
|
// 查询 CDN 刷新记录
|
||||||
|
// 参考文档:https://developer.qiniu.com/fusion/api/1229/cache-refresh#4
|
||||||
|
|
||||||
|
$requestId = 'xxxxxx'; // 指定要查询记录所在的刷新请求id
|
||||||
|
$isDir = 'no'; // 指定是否查询目录,取值为yes/no,默认不填则为两种类型记录都查询
|
||||||
|
|
||||||
|
// 要查询的url列表,每个url可以是文件url,也可以是目录url
|
||||||
|
$urls = array(
|
||||||
|
"http://sdk.peterpy.cn/sdktest.png",
|
||||||
|
"http://sdk.peterpy.cn/qiniulogo.png"
|
||||||
|
);
|
||||||
|
|
||||||
|
$state = 'success'; // 指定要查询记录的状态,取值 processing/success/failure
|
||||||
|
$pageNo = 0; // 要求返回的页号,默认为0
|
||||||
|
$pageSize = 100; // 要求返回的页长度,默认为100
|
||||||
|
$startTime = '2020-09-11 12:00:00'; // 指定查询的开始日期,格式2006-01-01
|
||||||
|
$endTime = '2020-09-20 21:00:00'; // 指定查询的结束日期,格式2006-01-01
|
||||||
|
|
||||||
|
list($ret, $err) = $cdnManager->getCdnRefreshList(
|
||||||
|
$requestId,
|
||||||
|
$isDir,
|
||||||
|
$urls,
|
||||||
|
$state,
|
||||||
|
$pageNo,
|
||||||
|
$pageSize,
|
||||||
|
$startTime,
|
||||||
|
$endTime
|
||||||
|
);
|
||||||
|
echo "\n====> query refresh list: \n";
|
||||||
|
if ($err !== null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
59
php-sdk/examples/cdn_refresh_urls_dirs.php
Normal file
59
php-sdk/examples/cdn_refresh_urls_dirs.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Cdn\CdnManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
|
||||||
|
//---------------------------------------- demo1 ----------------------------------------
|
||||||
|
// 刷新文件和目录
|
||||||
|
// 文件列表一次最多提交 60 个,目录一次最多提交 10 个
|
||||||
|
// 参考文档:https://developer.qiniu.com/fusion/api/1229/cache-refresh
|
||||||
|
|
||||||
|
$urls = array(
|
||||||
|
"http://phpsdk.qiniudn.com/qiniu.jpg",
|
||||||
|
"http://phpsdk.qiniudn.com/qiniu2.jpg",
|
||||||
|
);
|
||||||
|
|
||||||
|
$dirs = array(
|
||||||
|
"http://phpsdk.qiniudn.com/test/"
|
||||||
|
);
|
||||||
|
|
||||||
|
$cdnManager = new CdnManager($auth);
|
||||||
|
|
||||||
|
// 如果刷新返回 400038 报错,则需要联系七牛技术支持开通刷新目录权限,参考:https://developer.qiniu.com/fusion/api/1229/cache-refresh,
|
||||||
|
list($refreshResult, $refreshErr) = $cdnManager->refreshUrlsAndDirs($urls, $dirs);
|
||||||
|
if ($refreshErr != null) {
|
||||||
|
var_dump($refreshErr);
|
||||||
|
} else {
|
||||||
|
echo "refresh request sent\n";
|
||||||
|
print_r($refreshResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------- demo2 ----------------------------------------
|
||||||
|
// 刷新文件
|
||||||
|
|
||||||
|
list($refreshResult, $refreshErr) = $cdnManager->refreshUrls($urls);
|
||||||
|
if ($refreshErr != null) {
|
||||||
|
var_dump($refreshErr);
|
||||||
|
} else {
|
||||||
|
echo "refresh urls request sent\n";
|
||||||
|
print_r($refreshResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------- demo3 ----------------------------------------
|
||||||
|
// 刷新目录
|
||||||
|
|
||||||
|
list($refreshResult, $refreshErr) = $cdnManager->refreshDirs($dirs);
|
||||||
|
if ($refreshErr != null) {
|
||||||
|
var_dump($refreshErr);
|
||||||
|
} else {
|
||||||
|
echo "refresh dirs request sent\n";
|
||||||
|
print_r($refreshResult);
|
||||||
|
}
|
||||||
20
php-sdk/examples/cdn_timestamp_antileech.php
Normal file
20
php-sdk/examples/cdn_timestamp_antileech.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Cdn\CdnManager;
|
||||||
|
|
||||||
|
// 创建带时间戳防盗链的 URL
|
||||||
|
// 参考文档:https://developer.qiniu.com/fusion/manual/3841/timestamp-hotlinking-prevention-fusion
|
||||||
|
|
||||||
|
$encryptKey = 'your_domain_timestamp_antileech_encryptkey';
|
||||||
|
|
||||||
|
// 一定要带访问协议,也就是 http:// 或者 https://
|
||||||
|
$url1 = 'http://phpsdk.qiniuts.com/24.jpg?imageInfo';
|
||||||
|
$url2 = 'http://phpsdk.qiniuts.com/24.jpg';
|
||||||
|
|
||||||
|
// 有效期时间(单位秒)
|
||||||
|
$durationInSeconds = 3600;
|
||||||
|
|
||||||
|
$signedUrl = CdnManager::createTimestampAntiLeechUrl($url1, $encryptKey, $durationInSeconds);
|
||||||
|
print($signedUrl);
|
||||||
42
php-sdk/examples/censor_image.php
Normal file
42
php-sdk/examples/censor_image.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Config;
|
||||||
|
use Qiniu\Storage\ArgusManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
|
||||||
|
$config = new Config();
|
||||||
|
$argusManager = new ArgusManager($auth, $config);
|
||||||
|
|
||||||
|
// 图片内容审核
|
||||||
|
// 参考文档:https://developer.qiniu.com/censor/api/5588/image-censor
|
||||||
|
|
||||||
|
$body = '{
|
||||||
|
"data":{
|
||||||
|
"uri":"https://www-static.qbox.me/_next/static/media/pic01.c8b5db2cc5fcb6fc4e6349c9e37c8e6b.png"
|
||||||
|
},
|
||||||
|
"params":{
|
||||||
|
"scenes":[
|
||||||
|
"pulp",
|
||||||
|
"terror",
|
||||||
|
"politician",
|
||||||
|
"ads"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}';
|
||||||
|
|
||||||
|
list($ret, $err) = $argusManager->censorImage($body);
|
||||||
|
echo "\n====> Result is: \n";
|
||||||
|
if ($err !== null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
52
php-sdk/examples/censor_video.php
Normal file
52
php-sdk/examples/censor_video.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Config;
|
||||||
|
use Qiniu\Storage\ArgusManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
|
||||||
|
$config = new Config();
|
||||||
|
$argusManager = new ArgusManager($auth, $config);
|
||||||
|
|
||||||
|
// 视频内容审核
|
||||||
|
// 参考文档:https://developer.qiniu.com/censor/api/5620/video-censor
|
||||||
|
|
||||||
|
$body = '{
|
||||||
|
"data":{
|
||||||
|
"uri":"https://dn-mars-assets.qbox.me/Fi1UC6waXtXYCpnTGHa8XxIziGNk"
|
||||||
|
},
|
||||||
|
"params":{
|
||||||
|
"scenes":[
|
||||||
|
"pulp",
|
||||||
|
"terror",
|
||||||
|
"politician",
|
||||||
|
"ads"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}';
|
||||||
|
|
||||||
|
list($jobid, $err) = $argusManager->censorVideo($body);
|
||||||
|
echo "\n====> Result is: \n";
|
||||||
|
if ($err !== null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
echo "job_id is: $jobid\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询视频审核结果
|
||||||
|
list($ret, $err) = $argusManager->censorStatus($jobid);
|
||||||
|
echo "\n====> job status: \n";
|
||||||
|
|
||||||
|
if ($err != null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
27
php-sdk/examples/delete_bucket.php
Normal file
27
php-sdk/examples/delete_bucket.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Config;
|
||||||
|
use Qiniu\Storage\BucketManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$config = new Config();
|
||||||
|
$bucketManager = new BucketManager($auth, $config);
|
||||||
|
|
||||||
|
// 删除指定的 Bucket
|
||||||
|
// 1、空间绑定了自定义域名,禁止删除,需要先解绑域名
|
||||||
|
// 2、空间不为空,禁止删除,需要先把空间内的文件删除完毕
|
||||||
|
|
||||||
|
$bucket = 'xxxx'; // 存储空间名称
|
||||||
|
|
||||||
|
list($ret, $err) = $bucketManager->deleteBucket($bucket);
|
||||||
|
if ($err != null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
28
php-sdk/examples/delete_bucketEvent.php
Normal file
28
php-sdk/examples/delete_bucketEvent.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Config;
|
||||||
|
use Qiniu\Storage\BucketManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$config = new Config();
|
||||||
|
$bucketManager = new BucketManager($auth, $config);
|
||||||
|
|
||||||
|
// 删除 bucket 事件通知规则
|
||||||
|
// 参考文档:https://developer.qiniu.com/kodo/manual/6095/event-notification
|
||||||
|
|
||||||
|
$bucket = 'xxxx'; // 存储空间名称
|
||||||
|
|
||||||
|
$name = 'demo'; // 规则名称 bucket 内唯一,由 1 ~ 50 个字符组成,可包含:字母、数字和下划线
|
||||||
|
|
||||||
|
list($ret, $err) = $bucketManager->deleteBucketEvent($bucket, $name);
|
||||||
|
if ($err != null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
27
php-sdk/examples/delete_bucketLifecycleRule.php
Normal file
27
php-sdk/examples/delete_bucketLifecycleRule.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Config;
|
||||||
|
use Qiniu\Storage\BucketManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$config = new Config();
|
||||||
|
$bucketManager = new BucketManager($auth, $config);
|
||||||
|
|
||||||
|
// 删除存储空间 - 生命周期规则
|
||||||
|
// 参考文档:https://developer.qiniu.com/kodo/manual/3699/life-cycle-management
|
||||||
|
|
||||||
|
$bucket = 'xxxx'; // 存储空间名称
|
||||||
|
$name = 'demo'; // 生命周期规则名称
|
||||||
|
|
||||||
|
list($ret, $err) = $bucketManager->deleteBucketLifecycleRule($bucket, $name);
|
||||||
|
if ($err != null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
26
php-sdk/examples/get_bucketEvents.php
Normal file
26
php-sdk/examples/get_bucketEvents.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Config;
|
||||||
|
use Qiniu\Storage\BucketManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$config = new Config();
|
||||||
|
$bucketManager = new BucketManager($auth, $config);
|
||||||
|
|
||||||
|
// 获取存储空间 - 事件通知规则
|
||||||
|
// 参考文档:https://developer.qiniu.com/kodo/manual/6095/event-notification
|
||||||
|
|
||||||
|
$bucket = 'xxxx'; // 存储空间名称
|
||||||
|
|
||||||
|
list($ret, $err) = $bucketManager->getBucketEvents($bucket);
|
||||||
|
if ($err != null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
26
php-sdk/examples/get_bucketLifecycleRules.php
Normal file
26
php-sdk/examples/get_bucketLifecycleRules.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../autoload.php';
|
||||||
|
|
||||||
|
use Qiniu\Auth;
|
||||||
|
use Qiniu\Config;
|
||||||
|
use Qiniu\Storage\BucketManager;
|
||||||
|
|
||||||
|
// 控制台获取密钥:https://portal.qiniu.com/user/key
|
||||||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||||||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||||||
|
|
||||||
|
$auth = new Auth($accessKey, $secretKey);
|
||||||
|
$config = new Config();
|
||||||
|
$bucketManager = new BucketManager($auth, $config);
|
||||||
|
|
||||||
|
// 获取存储空间 - 生命周期规则
|
||||||
|
// 参考文档:https://developer.qiniu.com/kodo/manual/3699/life-cycle-management
|
||||||
|
|
||||||
|
$bucket = 'xxxx'; // 存储空间名称
|
||||||
|
|
||||||
|
list($ret, $err) = $bucketManager->getBucketLifecycleRules($bucket);
|
||||||
|
if ($err != null) {
|
||||||
|
var_dump($err);
|
||||||
|
} else {
|
||||||
|
var_dump($ret);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user