replace alioss sdk 2.3.0 with version 2.3.1

This commit is contained in:
MooN 2020-06-25 15:13:15 +08:00
parent f737eb5738
commit 3f3d124873
148 changed files with 1042 additions and 926 deletions

View File

@ -1,6 +1,6 @@
<?php
require_once 'aliyun-oss-php-sdk-2.3.0/autoload.php';
require_once 'aliyun-oss-php-sdk-2.3.1/autoload.php';
use OSS\OssClient;
use OSS\Core\OssException;
@ -195,7 +195,7 @@ class AliOssForTypecho_Plugin implements Typecho_Plugin_Interface
* @return mixed
*/
public static function uploadHandle($file)
{
{
if (empty($file['name'])) {
return FALSE;
}

View File

@ -1,92 +0,0 @@
# ChangeLog - Aliyun OSS SDK for PHP
## v2.3.0 / 2018-01-05
* 修复putObject支持创建空文件
* 修复createBucket支持IA/Archive
* 增加支持restoreObject
* 增加支持Symlink功能
* 增加支持getBucketLocation
* 增加支持getBucketMeta
* 增加支持代理服务器Proxy
## v2.2.4 / 2017-04-25
* fix getObject to local file bug
## v2.2.3 / 2017-04-14
* fix md5 check
## v2.2.2 / 2017-01-18
* 解决在php7上运行连接数和内存bug
## v2.2.1 / 2016-12-01
* 禁止http curl自动填充Accept-Encoding
## v2.2.0 / 2016-11-22
* 修复PutObject/CompleteMultipartUpload的返回值问题(#26)
## v2.1.0 / 2016-11-12
* 增加[RTMP](https://help.aliyun.com/document_detail/44297.html)接口
* 增加支持[图片服务](https://help.aliyun.com/document_detail/44686.html)
## v2.0.7 / 2016-06-17
* Support append object
## v2.0.6
* Trim access key id/secret and endpoint
* Refine tests and setup travis CI
## v2.0.5
* 增加Add/Delete/Get BucketCname接口
## v2.0.4
* 增加Put/Get Object Acl接口
## v2.0.3
* 修复Util中的常量定义在低于5.6的PHP版本中报错的问题
## v2.0.2
* 修复multipart上传时无法指定Content-Type的问题
## v2.0.1
* 增加对ListObjects/ListMultipartUploads时特殊字符的处理
* 提供接口获取OssException中的详细信息
## 2015.11.25
* **大版本升级,不再兼容以前接口,新版本对易用性做了很大的改进,建议用户迁移到新版本。**
## 修改内容
* 不再支持PHP 5.2版本
### 新增内容
* 引入命名空间
* 接口命名修正,采用驼峰式命名
* 接口入参修改把常用参数从Options参数中提出来
* 接口返回结果修改,对返回结果进行处理,用户可以直接得到容易处理的数据结构 
* OssClient的构造函数变更
* 支持CNAME和IP格式的Endpoint地址
* 重新整理sample文件组织结构使用function组织功能点
* 增加设置连接超时,请求超时的接口
* 去掉Object Group相关的已经过时的接口
* OssException中的message改为英文
### 问题修复
* object名称校验不完备

View File

@ -1,15 +0,0 @@
<?php
/**
* Class Config
*
* 执行Sample示例所需要的配置用户在这里配置好EndpointAccessId AccessKey和Sample示例操作的
* bucket后便可以直接运行RunAll.php, 运行所有的samples
*/
final class Config
{
const OSS_ACCESS_ID = '';
const OSS_ACCESS_KEY = '';
const OSS_ENDPOINT = '';
const OSS_TEST_BUCKET = '';
}

View File

@ -1,9 +0,0 @@
<?php
require_once 'autoload.php';
use OSS\OssClient;
use OSS\Core\OssException;
$client = new OssClient('U6GLwyx2g6jrOL1V', 'W05IEVd3nio2BVCG5GoMG6QekiO1di', 'http://oss-cn-qingdao.aliyuncs.com');

View File

@ -0,0 +1,2 @@
coverage_clover: coverage.xml
json_path: coverage.json

8
aliyun-oss-php-sdk-2.3.1/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
vendor
composer.lock
doc
output
.idea
.buildpath
.project
.settings

View File

@ -0,0 +1,21 @@
language: php
php:
- 7.1
- 7.0
- 5.6
- 5.5
- 5.4
install:
- composer self-update
- composer install --no-interaction
script:
- php vendor/bin/phpunit
after_success:
- php vendor/bin/coveralls -v
env:
global:
- secure: SzmQ854lQmhV6ZkAG7lQNTY3CkazrXnDSb6VMwPU/sdaLGxPO159AW3fJS5d0sO/XN1P8x5WNkoA4i9soDlLBRibEEISNUM/2EMnpszsRymZ9o97PrS2IgORXTUL/OF+rpATzyNVB2p+2l9hBLiGf17exMSA5iOeY7W6E+VKPGi8TFykgbGUnLKU0h1hV3rzmtfGjOXcSpvYU/hxeZD/J/+6m5Gic9b/pNS+AbfTj7Y7Ru9tNsnyUP29V/vtEYtpQir3ZxQiSiUv9idybgGnJBOMYydJofb/mpFYHhYLSWqtMKGNLpeawmqs4z8S1Tvx5U5uzW5+h/mpzhvBaFlWGpm8t89BQxun5LVX5NiYCrV7TqaLitGp1cSpMjMDnrnSTNzk1exVz+rWZZcWS7yB9ULYA681GA8StXWk167qB7Y30iK1dFK3+2mDN2cEY+qLs8+bupDowQ4eOM+eqfhxX8F8+ouKcKomETsjiIwL+CUsIe6wjvnYFWb1YlRhbsI75bblHApflohnt6gVSJ78ZPqID+u2oUMjmIWXLTnRR2Y2tgEW8uqHeIoQ8BBntLdQDmv0BO4FpnGQIwrUUwQYeNzEM0DOr3hWZhyDR6Xvl+9H0l52xjANaSqpuTZfC3zmeFTG7kIjydvxNePRrony6XAawL9BvI7aKWuVF6YVjPM=
- secure: nEhsU8aUQqsAJeuger+boh51oTpeo4YNG7vUWbKxdwVDIrcLb+l7r7RvTlxU7mt8IZTWwicgri18mh+Wi04BwX4ulBA1SCs8jPbL51KEo5izoDGGtLSd2fuPHdslYSrwagrvq90EPnDT/7fHWn/TAoT+rueZzjNyCu5IGSgL3GnXaUThsJ82NMePL2YRdP4Q1qmtZPRFBOkOQ6F0heuV8fw8sLyTO3txaCQum9YneGxrWxOl/E8zB0qtlnPwLE8ogaHZMQh2/jThmTbI5UqwRTxV4f0qoD5eJYH+j0fslsSAjsg/HPnSuVcnccK3zSU+s2sV4dPCcISzECJvZEObwipfxOGhdqt5gMcxHhn8qVsbT97iIh106pG/BJCDgQd2EeVW8WfCi6cCuCKIMipvVkMypkmjQHWU1XaqPzILl7g5diW9Ctp2C4Akq5dYdrdu8IrnVK1ShtkQVaWU+S/Bht8VU5gYP7olPW/GdTz7sceU1NOIC4NPXqmWKbfavR98U5dkHMLMvzABYL1Q87h+KhPD1c14NUyw3YENUW7REiF/X5lERRm5H0kJ/1JqAa+AgeHQEGmPVuZV2s/na4b0S1479QRVmSM/6ZzXQpU+Y8jCRfETpUFA4S331369kirHgCqDlxyIntuEKrzivD02/O+5C3eJ0WHRz6QsN2/R4qg=
- secure: ZTvzNXEZP4efl+a/3VGMmdabfUQp83v5/lecMns039Ro7UuZYPdtbPtpPnpjaTI6Htd22A4Rva5BU/3JCQJAyQvpbKNn5sGou2SmfQu3o0SyhggSB7gWjYAf707aW1j4bHYfP8IjDS5NjuVk3AqXeNSUuLRUXRmwSOB0lSYiRhiTJY+pUdBl382Hx4NbhIU/gmOzRoJCs7coTip8IURXYEHPi5dnDWluajxI+TgNXFccSgEleeQDJajYgXmpLb2EhSj8piipOnVgaCEE5bh5fbp32024Qq38SGHKcbfnwj2IInpZpZESJknRKoqAlFjdOJhork82dBcvAr5JxCBZKx5IuwXcTjxkQ6tRtBeqhPLPFuX3MQ8WrtU+wniPM0RCH/VoFkUKO7JGQDwmoi2AKago4PsuDs4P6Y6CeuOVpcso731GwwMNhIJcyrJJivXprQNEGsEw+9wLjU1qNYs6IIA3S/gPzFrNbdX5Wf8vxt0vLpgYvBNtPnLMejMtknuyfVzf5iKuVVoGPDTEz+ajs06+jfoPfm/4sLTaLghuVH7Adm74OpF769JQNnQYKwJuu4bNlcbLJChulCEMBOx7myqo/9O6RCTuqzHaGmVWNot4RGqRFHgJGl/JJf0WpAVitbhbRH3kGoyKb6jFM74CJbPsE7OORlJLDC3cdD3C8Pk=
- secure: Qr5NR4CVzBKCQgRgMH0x772TPJ1+brx3UCvtRNu8fi4j3p8bz+HDMjBaBDSFmEB09nunLI55/8mj88/5GXmnpFs8+CPTkcW+QZOcxg3cxpI4SNmxoB12/ZawlFHAqSUaRRE7RUWVkY3KL8tIGjEZcFyUBQ1DVNX3OMpiKs3NLtHa7oUIknyBxdSokm4kpLhSXYe7WmO0vhuZbMZE0S1EISToiBS6AdhGUEbTLJ/vNsIDY07fu6+Vh3HxVbyUFPqUZGlkZpQ+2xMJ3kiqPBMrXtRF/IhhPjORDil6Ns9SQ8/AAlaCddvYvRaT4Pjv2/aX+t3l28qI1qmryPtWXpce5UXecWGYqdRpSJc6Y/pEt4m4FeeGoEFWnSPGIs7FRmeiis8q2rojGZ18i4vI/k4iHmqEBnTlMp3SWnRb9L1adJ8ZAWln8aC88gkQXm67w7+1CxLycerbYj9H1ugqHENuHcxv4uHUcZgEENX3EWatu8i9+K2IUuU/2zcmpu7qtsziYcoyW8DOOmYpJfXGMLtmF9+pqp/Tp6i0tltFSEfmY3N8o7xvv3enLvFHsjL+3ElFdd1blUPSrvZJHgA9M3lJ+QF1RJZCpJqgPlQ0XOZK1Bf4P46zpEj01wKaK4JQrkLPRXhbBOuIJn5O6WlFJyPX4+SaBfwTzb4AvM4aUg2TgTg=
- secure: Inw5ftA8fxvhMHRZwoZzATxn4WICJsCq7ZX4y2gI+b/8u0JQIsbLgY9WTYV+XdSxOoNwuVa1oUxEWI0aDORtXKC3XaIXXKrwndag0zxS77JEYwWvQsjM7BhEbF7MF7MYk8rRXpn6mbfGAT/NfqEOx91RCY8UKeMzD0oPkpkBnJ9Ekuod6JBBq+7j3v4mYUItA8pxvw7b4Pdd4z2xzjgOwNhJYMOCpts50DWZI+WXj0HvTYaMXe5mJJtORK5lsr0a9cbsBqAzE6l+3zGI8XkgHn130ux5XH3DE7hZBeti3ZNaO3d2Vv+496/1EObG0rSFk+z3dmNKqjMz4nh3bYIkdLMegwmgCWs2mvQhkwYhzmnPRHVSERrgZjSWnuKn2PKnBar6tui9KaLNgpo2j3jWpwMLJ3bGAfE5JtMppxAxNqj/q+YB2UZo7Mn7EDjkTDjgxCuazTJwWqH7xxCOykWPABBI17P3JaOXQJEK39LavpfSMm3kdmU0ocpUs7FniLuFm6xL71VxY1wHG10yskczEcFHZ3iyIyGM+xum4vbt5y6Yg+zfdExYQsbrxHDDZ3HbHY3tEU0WhM55vrC42NIXRWqXqJ8OAxpl4nivfx96eoBAThiUU9xXtZmh7WRFVYsstoGtxZwfk5+bi+oeVO9kih4xabwbgHgL9BTc1TR1C4U=

View File

@ -0,0 +1,97 @@
# ChangeLog - Aliyun OSS SDK for PHP
## v2.3.1 / 2019-011-15
* translate chinese comments into english
* Added: endpoint validity check
## v2.3.0 / 2018-01-05
* Fixed: putObject support creating empty files
* Fixed: createBucket support IA/Archive
* Added: support restoreObject
* Added: support the Symlink feature
* Added: support getBucketLocation
* Added: support getBucketMeta
* Added: support proxy server Proxy
## v2.2.4 / 2017-04-25
* Fixed getObject to local file bug
## v2.2.3 / 2017-04-14
* Fixed md5 check
## v2.2.2 / 2017-01-18
* Resolve to run the connection number and memory bug on php7
## v2.2.1 / 2016-12-01
* No HTTP curl is allowed to automatically populate accept-encoding
## v2.2.0 / 2016-11-22
* Fixed PutObject/CompleteMultipartUpload return values(#26)
## v2.1.0 / 2016-11-12
* Added[RTMP](https://help.aliyun.com/document_detail/44297.html)interface
* Add support[image service](https://help.aliyun.com/document_detail/44686.html)
## v2.0.7 / 2016-06-17
* Support append object
## v2.0.6
* Trim access key id/secret and endpoint
* Refine tests and setup travis CI
## v2.0.5
* Added Add/Delete/Get BucketCname interface
## v2.0.4
* Added Put/Get Object Acl interface
## v2.0.3
* Fixing the constants in Util is defined in a PHP version that is less than 5.6.
## v2.0.2
* The problem of content-type cannot be specified when restoring multipart uploads
## v2.0.1
* Increase the ListObjects/ListMultipartUploads special characters
* Provides the interface to get the details of the OssException
## 2015.11.25
* **Large version upgrade, no longer compatible with previous interface, new version has made great improvements to ease of use, suggesting that users migrate to a new version.**
## Modify the content
* PHP 5.2 is no longer supported
### Add the cotent
* Introduce namespace
* Interface naming and modification, using hump naming
* The interface is modified, and the common parameters are extracted from the Options parameter.
* The interface returns the result modification, processing the return result, and the user can directly get the data structure easily processed 
* OssClient's constructor changes
* The Endpoint address that support CNAME and IP formats
* Rearrange the sample file organization structure and use function to organize the function points
* Add an interface that sets the connection timeout and requests timeout
* Remove the outdated interface associated with the Object Group
* The message in the OssException is changed to English
### Repair problem
* The object name is not complete

View File

@ -6,7 +6,6 @@ function classLoader($class)
$file = __DIR__ . DIRECTORY_SEPARATOR .'src'. DIRECTORY_SEPARATOR . $path . '.php';
if (file_exists($file)) {
require_once $file;
} else {
}
}
spl_autoload_register('classLoader');

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -8,28 +8,28 @@ $ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
$bucket = Common::getBucketName();
//******************************* 简单使用 ****************************************************************
//******************************* Simple Usage****************************************************************
//创建bucket
// Create a bucket
$ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
Common::println("bucket $bucket created");
// 判断Bucket是否存在
// Check whether a bucket exists
$doesExist = $ossClient->doesBucketExist($bucket);
Common::println("bucket $bucket exist? " . ($doesExist ? "yes" : "no"));
// 获取Bucket列表
// Get the bucket list
$bucketListInfo = $ossClient->listBuckets();
// 设置bucket的ACL
// Set bucket ACL
$ossClient->putBucketAcl($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
Common::println("bucket $bucket acl put");
// 获取bucket的ACL
// Get bucket ACL
$acl = $ossClient->getBucketAcl($bucket);
Common::println("bucket $bucket acl get: " . $acl);
//******************************* 完整用法参考下面函数 ****************************************************
//******************************* For complete usage, see the following functions ****************************************************
createBucket($ossClient, $bucket);
doesBucketExist($ossClient, $bucket);
@ -39,13 +39,13 @@ getBucketAcl($ossClient, $bucket);
listBuckets($ossClient);
/**
* 创建一个存储空间
* acl 指的是bucket的访问控制权限有三种私有读写公共读私有写公共读写。
* 私有读写就是只有bucket的拥有者或授权用户才有权限操作
* 三种权限分别对应 (OssClient::OSS_ACL_TYPE_PRIVATEOssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE)
* Create a new bucket
* acl indicates the access permission of a bucket, including: private, public-read-only/private-read-write, and public read-write.
* Private indicates that only the bucket owner or authorized users can access the data..
* The three permissions are separately defined by (OssClient::OSS_ACL_TYPE_PRIVATE,OssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE)
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 要创建的存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket Name of the bucket to create
* @return null
*/
function createBucket($ossClient, $bucket)
@ -61,10 +61,10 @@ function createBucket($ossClient, $bucket)
}
/**
* 判断Bucket是否存在
* Check whether a bucket exists.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
*/
function doesBucketExist($ossClient, $bucket)
{
@ -83,10 +83,11 @@ function doesBucketExist($ossClient, $bucket)
}
/**
* 删除bucket如果bucket不为空则bucket无法删除成功 不为空表示bucket既没有object也没有未完成的multipart上传时的parts
* Delete a bucket. If the bucket is not empty, the deletion fails.
* A bucket which is not empty indicates that it does not contain any objects or parts that are not completely uploaded during multipart upload
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 待删除的存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket Name of the bucket to delete
* @return null
*/
function deleteBucket($ossClient, $bucket)
@ -102,10 +103,10 @@ function deleteBucket($ossClient, $bucket)
}
/**
* 设置bucket的acl配置
* Set bucket ACL
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function putBucketAcl($ossClient, $bucket)
@ -123,10 +124,10 @@ function putBucketAcl($ossClient, $bucket)
/**
* 获取bucket的acl配置
* Get bucket ACL
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getBucketAcl($ossClient, $bucket)
@ -144,9 +145,9 @@ function getBucketAcl($ossClient, $bucket)
/**
* 列出用户所有的Bucket
* List all buckets
*
* @param OssClient $ossClient OssClient实例
* @param OssClient $ossClient OssClient instance
* @return null
*/
function listBuckets($ossClient)

View File

@ -11,9 +11,9 @@ if (is_null($ossClient)) exit(1);
$bucket = Common::getBucketName();
//******************************* 简单使用 ****************************************************************
//******************************* Simple usage****************************************************************
// 设置cors配置
// Set cors configuration
$corsConfig = new CorsConfig();
$rule = new CorsRule();
$rule->addAllowedHeader("x-oss-header");
@ -24,15 +24,15 @@ $corsConfig->addRule($rule);
$ossClient->putBucketCors($bucket, $corsConfig);
Common::println("bucket $bucket corsConfig created:" . $corsConfig->serializeToXml());
// 获取cors配置
// Get cors configuration
$corsConfig = $ossClient->getBucketCors($bucket);
Common::println("bucket $bucket corsConfig fetched:" . $corsConfig->serializeToXml());
// 删除cors配置
// Delete cors configuration
$ossClient->deleteBucketCors($bucket);
Common::println("bucket $bucket corsConfig deleted");
//******************************* 完整用法参考下面函数 *****************************************************
//******************************* For complete usage, see the following functions *****************************************************
putBucketCors($ossClient, $bucket);
getBucketCors($ossClient, $bucket);
@ -40,10 +40,10 @@ deleteBucketCors($ossClient, $bucket);
getBucketCors($ossClient, $bucket);
/**
* 设置bucket的cors配置
* Set bucket cores
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function putBucketCors($ossClient, $bucket)
@ -67,10 +67,10 @@ function putBucketCors($ossClient, $bucket)
}
/**
* 获取并打印bucket的cors配置
* Get and print the cors configuration of a bucket
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getBucketCors($ossClient, $bucket)
@ -88,10 +88,10 @@ function getBucketCors($ossClient, $bucket)
}
/**
* 删除bucket的所有的cors配置
* Delete all cors configuraiton of a bucket
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function deleteBucketCors($ossClient, $bucket)

View File

@ -11,9 +11,9 @@ $bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//******************************* 简单使用 *******************************************************
//******************************* Simple Usage *******************************************************
//设置lifecycle规则
// Set lifecycle configuration
$lifecycleConfig = new LifecycleConfig();
$actions = array();
$actions[] = new LifecycleAction("Expiration", "Days", 3);
@ -22,16 +22,16 @@ $lifecycleConfig->addRule($lifecycleRule);
$ossClient->putBucketLifecycle($bucket, $lifecycleConfig);
Common::println("bucket $bucket lifecycleConfig created:" . $lifecycleConfig->serializeToXml());
//获取lifecycle规则
// Get lifecycle configuration
$lifecycleConfig = $ossClient->getBucketLifecycle($bucket);
Common::println("bucket $bucket lifecycleConfig fetched:" . $lifecycleConfig->serializeToXml());
//删除bucket的lifecycle配置
// Delete bucket lifecycle configuration
$ossClient->deleteBucketLifecycle($bucket);
Common::println("bucket $bucket lifecycleConfig deleted");
//***************************** 完整用法参考下面函数 ***********************************************
//***************************** For complete usage, see the following functions ***********************************************
putBucketLifecycle($ossClient, $bucket);
getBucketLifecycle($ossClient, $bucket);
@ -39,10 +39,10 @@ deleteBucketLifecycle($ossClient, $bucket);
getBucketLifecycle($ossClient, $bucket);
/**
* 设置bucket的生命周期配置
* Set bucket lifecycle configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function putBucketLifecycle($ossClient, $bucket)
@ -67,10 +67,10 @@ function putBucketLifecycle($ossClient, $bucket)
}
/**
* 获取bucket的生命周期配置
* Get bucket lifecycle configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getBucketLifecycle($ossClient, $bucket)
@ -88,10 +88,10 @@ function getBucketLifecycle($ossClient, $bucket)
}
/**
* 删除bucket的生命周期配置
* Delete bucket lifecycle configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function deleteBucketLifecycle($ossClient, $bucket)

View File

@ -8,21 +8,21 @@ $bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
//*******************************Simple Usage ***************************************************************
// 设置Bucket访问日志记录规则, 访问日志文件的存放位置是同bucket下的access.log前缀的文件
// Set bucket access logging rules. Access logs are stored under the same bucket with a 'access.log' prefix.
$ossClient->putBucketLogging($bucket, $bucket, "access.log", array());
Common::println("bucket $bucket lifecycleConfig created");
// 获取Bucket访问日志记录规则
// Get bucket access logging rules
$loggingConfig = $ossClient->getBucketLogging($bucket, array());
Common::println("bucket $bucket lifecycleConfig fetched:" . $loggingConfig->serializeToXml());
// 删除Bucket访问日志记录规则
// Delete bucket access logging rules
$loggingConfig = $ossClient->getBucketLogging($bucket, array());
Common::println("bucket $bucket lifecycleConfig deleted");
//******************************* 完整用法参考下面函数 ****************************************************
//******************************* For complete usage, see the following functions ****************************************************
putBucketLogging($ossClient, $bucket);
getBucketLogging($ossClient, $bucket);
@ -30,16 +30,16 @@ deleteBucketLogging($ossClient, $bucket);
getBucketLogging($ossClient, $bucket);
/**
* 设置bucket的Logging配置
* Set bucket logging configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function putBucketLogging($ossClient, $bucket)
{
$option = array();
//访问日志存放在本bucket下
// Access logs are stored in the same bucket.
$targetBucket = $bucket;
$targetPrefix = "access.log";
@ -54,10 +54,10 @@ function putBucketLogging($ossClient, $bucket)
}
/**
* 获取bucket的Logging配置
* Get bucket logging configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getBucketLogging($ossClient, $bucket)
@ -76,10 +76,10 @@ function getBucketLogging($ossClient, $bucket)
}
/**
* 删除bucket的Logging配置
* Delete bucket logging configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function deleteBucketLogging($ossClient, $bucket)

View File

@ -9,26 +9,26 @@ $bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//******************************* 简单使用 ****************************************************************
//******************************* Simple Usage ****************************************************************
//设置referer白名单
// Set referer whitelist
$refererConfig = new RefererConfig();
$refererConfig->setAllowEmptyReferer(true);
$refererConfig->addReferer("www.aliiyun.com");
$refererConfig->addReferer("www.aliiyuncs.com");
$ossClient->putBucketReferer($bucket, $refererConfig);
Common::println("bucket $bucket refererConfig created:" . $refererConfig->serializeToXml());
//获取Referer白名单
// Get referer whitelist
$refererConfig = $ossClient->getBucketReferer($bucket);
Common::println("bucket $bucket refererConfig fetched:" . $refererConfig->serializeToXml());
//删除referer白名单
// Delete referrer whitelist
$refererConfig = new RefererConfig();
$ossClient->putBucketReferer($bucket, $refererConfig);
Common::println("bucket $bucket refererConfig deleted");
//******************************* 完整用法参考下面函数 ****************************************************
//******************************* For complete usage, see the following functions ****************************************************
putBucketReferer($ossClient, $bucket);
getBucketReferer($ossClient, $bucket);
@ -36,10 +36,10 @@ deleteBucketReferer($ossClient, $bucket);
getBucketReferer($ossClient, $bucket);
/**
* 设置bucket的防盗链配置
* Set bucket referer configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function putBucketReferer($ossClient, $bucket)
@ -59,10 +59,10 @@ function putBucketReferer($ossClient, $bucket)
}
/**
* 获取bucket的防盗链配置
* Get bucket referer configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getBucketReferer($ossClient, $bucket)
@ -80,11 +80,11 @@ function getBucketReferer($ossClient, $bucket)
}
/**
* 删除bucket的防盗链配置
* Referer白名单不能直接清空,只能通过重新设置来覆盖之前的规则。
* Delete bucket referer configuration
* Referer whitelist cannot be directly deleted. So use a empty one to overwrite it.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function deleteBucketReferer($ossClient, $bucket)

View File

@ -9,22 +9,22 @@ $bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
//******************************* Simple Usage ***************************************************************
// 设置Bucket的静态网站托管模式
// Set bucket static website configuration
$websiteConfig = new WebsiteConfig("index.html", "error.html");
$ossClient->putBucketWebsite($bucket, $websiteConfig);
Common::println("bucket $bucket websiteConfig created:" . $websiteConfig->serializeToXml());
// 查看Bucket的静态网站托管状态
// Get bucket static website configuration
$websiteConfig = $ossClient->getBucketWebsite($bucket);
Common::println("bucket $bucket websiteConfig fetched:" . $websiteConfig->serializeToXml());
// 删除Bucket的静态网站托管模式
// Delete bucket static website configuration
$ossClient->deleteBucketWebsite($bucket);
Common::println("bucket $bucket websiteConfig deleted");
//******************************* 完整用法参考下面函数 ****************************************************
//******************************* For complete usage, see the following functions ****************************************************
putBucketWebsite($ossClient, $bucket);
getBucketWebsite($ossClient, $bucket);
@ -32,10 +32,10 @@ deleteBucketWebsite($ossClient, $bucket);
getBucketWebsite($ossClient, $bucket);
/**
* 设置bucket的静态网站托管模式配置
* Sets bucket static website configuration
*
* @param $ossClient OssClient
* @param $bucket string 存储空间名称
* @param $bucket string bucket name
* @return null
*/
function putBucketWebsite($ossClient, $bucket)
@ -52,10 +52,10 @@ function putBucketWebsite($ossClient, $bucket)
}
/**
* 获取bucket的静态网站托管状态
* Get bucket static website configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getBucketWebsite($ossClient, $bucket)
@ -73,10 +73,10 @@ function getBucketWebsite($ossClient, $bucket)
}
/**
* 删除bucket的静态网站托管模式配置
* Delete bucket static website configuration
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function deleteBucketWebsite($ossClient, $bucket)

View File

@ -7,14 +7,14 @@ $bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
//******************************* Simple Usage ***************************************************************
/** putObject 使用callback上传内容到oss文件
* callbackurl参数指定请求回调的服务器url
* callbackbodytype参数可为application/json或application/x-www-form-urlencoded, 可选参数默认为application/x-www-form-urlencoded
* OSS_CALLBACK_VAR参数可以不设置
/** putObject Upload content to an OSS file using callback.
* The callbackurl specifies the server url for the request callback.
* The callbackbodytype can be application/json or application/x-www-form-urlencoded,the optional parameters,the default for the application/x - WWW - form - urlencoded
* Users can choose not to set OSS_BACK_VAR
*/
$url =
$url =
'{
"callbackUrl":"callback.oss-demo.com:23450",
"callbackHost":"oss-cn-hangzhou.aliyuncs.com",
@ -35,17 +35,17 @@ Common::println($result['body']);
Common::println($result['info']['http_code']);
/**
* completeMultipartUpload 使用callback上传内容到oss文件
* callbackurl参数指定请求回调的服务器url
* callbackbodytype参数可为application/json或application/x-www-form-urlencoded, 可选参数默认为application/x-www-form-urlencoded
* OSS_CALLBACK_VAR参数可以不设置
*/
* completeMultipartUpload Upload content to an OSS file using callback.
* callbackurl specifies the server url for the request callback
* The callbackbodytype can be application/json or application/x-www-form-urlencoded,the optional parameters,the default for the application/x - WWW - form - urlencoded
* Users can choose not to set OSS_BACK_VAR.
*/
$object = "multipart-callback-test.txt";
$copiedObject = "multipart-callback-test.txt.copied";
$ossClient->putObject($bucket, $copiedObject, file_get_contents(__FILE__));
/**
* step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id
* step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id
*/
$upload_id = $ossClient->initiateMultipartUpload($bucket, $object);

View File

@ -14,7 +14,7 @@ use OSS\Core\OssException;
/**
* Class Common
*
* 示例程序【Samples/*.php】 的Common类用于获取OssClient实例和其他公用方法
* The Common class for 【Samples/*.php】 used to obtain OssClient instance and other common functions
*/
class Common
{
@ -24,9 +24,9 @@ class Common
const bucket = Config::OSS_TEST_BUCKET;
/**
* 根据Config配置得到一个OssClient实例
* Get an OSSClient instance according to config.
*
* @return OssClient 一个OssClient实例
* @return OssClient An OssClient instance
*/
public static function getOssClient()
{
@ -46,7 +46,7 @@ class Common
}
/**
* 工具方法创建一个存储空间如果发生异常直接exit
* A tool function which creates a bucket and exists the process if there are exceptions
*/
public static function createBucket()
{
@ -81,4 +81,4 @@ class Common
}
}
Common::createBucket();
# Common::createBucket();

View File

@ -0,0 +1,15 @@
<?php
/**
* Class Config
*
* Make configurations required by the sample.
* Users can run RunAll.php which runs all the samples after configuring Endpoint, AccessId, and AccessKey.
*/
final class Config
{
const OSS_ACCESS_ID = 'update me';
const OSS_ACCESS_KEY = 'update me';
const OSS_ENDPOINT = 'update me';
const OSS_TEST_BUCKET = 'update me';
}

View File

@ -9,54 +9,54 @@ $ossClient = Common::getOssClient();
$download_file = "download.jpg";
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
//******************************* Simple Usage ***************************************************************
// 先把本地的example.jpg上传到指定$bucket, 命名为$object
// Upload example.jpg to the specified bucket and rename it to $object.
$ossClient->uploadFile($bucketName, $object, "example.jpg");
// 图片缩放
// Image resize
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/resize,m_fixed,h_100,w_100", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageResize",$download_file);
// 图片裁剪
// Image crop
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/crop,w_100,h_100,x_100,y_100,r_1", );
$ossClient->getObject($bucketName, $object, $options);
printImage("iamgeCrop", $download_file);
// 图片旋转
// Image rotate
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/rotate,90", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageRotate", $download_file);
// 图片锐化
// Image sharpen
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/sharpen,100", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageSharpen", $download_file);
// 图片水印
// Add watermark into a image
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageWatermark", $download_file);
// 图片格式转换
// Image format convertion
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/format,png", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageFormat", $download_file);
// 获取图片信息
// Get image information
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/info", );
@ -65,7 +65,7 @@ printImage("imageInfo", $download_file);
/**
* 生成一个带签名的可用于浏览器直接打开的url, URL的有效期是3600秒
* Generate a signed url which could be used in browser to access the object. The expiration time is 1 hour.
*/
$timeout = 3600;
$options = array(
@ -74,7 +74,7 @@ $options = array(
$signedUrl = $ossClient->signUrl($bucketName, $object, $timeout, "GET", $options);
Common::println("rtmp url: \n" . $signedUrl);
//最后删除上传的$object
// Finally delete the $object uploaded.
$ossClient->deleteObject($bucketName, $object);
function printImage($func, $imageFile)

View File

@ -8,11 +8,14 @@ $bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//******************************* 简单使用 *******************************************************
//******************************* Simple Usage *******************************************************
/**
创建一个直播频道
频道的名称是test_rtmp_live。直播生成的m3u8文件叫做test.m3u8该索引文件包含3片ts文件每片ts文件的时长为5秒这只是一个建议值具体的时长取决于关键帧
* Create a Live Channel
* The live channel's name is test_rtmp_live.
* The play url file is named as test.m3u8, which includes 3 ts files.
* The time period of each file is 5 seconds.(It is recommneded value only for demo purpose, the actual period depends on the key frame.)
*
*/
$config = new LiveChannelConfig(array(
'description' => 'live channel test',
@ -29,9 +32,9 @@ Common::println("bucket $bucket liveChannel created:\n" .
"playurls: ". $info->getPlayUrls()[0] . "\n");
/**
对创建好的频道可以使用listBucketLiveChannels来进行列举已达到管理的目的。
prefix可以按照前缀过滤list出来的频道。
max_keys表示迭代器内部一次list出来的频道的最大数量这个值最大不能超过1000不填写的话默认为100。
* You can use listBucketLiveChannels to list and manage all existing live channels.
* Prefix can be used to filter listed live channels by prefix.
* Max_keys indicates the maximum numbers of live channels that can be listed in an iterator at one time. Its value is 1000 in maximum and 100 by default.
*/
$list = $ossClient->listBucketLiveChannels($bucket);
Common::println("bucket $bucket listLiveChannel:\n" .
@ -50,7 +53,9 @@ foreach($list->getChannelList() as $list)
"list live channel getNextMarker: ". $list->getLastModified() . "\n");
}
/**
创建直播频道之后拿到推流用的play_urlrtmp推流的url如果Bucket不是公共读写权限那么还需要带上签名见下文示例和推流用的publish_url推流产生的m3u8文件的url
* Obtain the play_url (url used for rtmp stream pushing.
* If the the bucket is not globally readable and writable,
* the url must be signed as shown in the following.) and pulish_url (the url included in the m3u8 file generated in stream pushing) used to push streams.
*/
$play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600, array('params' => array('playlistName' => 'playlist.m3u8')));
Common::println("bucket $bucket rtmp url: \n" . $play_url);
@ -58,12 +63,13 @@ $play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600);
Common::println("bucket $bucket rtmp url: \n" . $play_url);
/**
创建好直播频道如果想把这个频道禁用掉断掉正在推的流或者不再允许向一个地址推流应该使用putLiveChannelStatus接口将频道的status改成“Disabled”如果要将一个禁用状态的频道启用那么也是调用这个接口将status改成“Enabled”
* If you want to disable a created live channel (disable the pushing streaming or do not allow stream pushing to an IP address), call putLiveChannelStatus to change the channel status to "Disabled".
* If you want to enable a disabled live channel, call PutLiveChannelStatus to chanage the channel status to "Enabled".
*/
$resp = $ossClient->putLiveChannelStatus($bucket, "test_rtmp_live", "enabled");
/**
创建好直播频道之后调用getLiveChannelInfo可以得到频道相关的信息
* You can callLiveChannelInfo to get the information about a live channel.
*/
$info = $ossClient->getLiveChannelInfo($bucket, 'test_rtmp_live');
Common::println("bucket $bucket LiveChannelInfo:\n" .
@ -75,7 +81,7 @@ Common::println("bucket $bucket LiveChannelInfo:\n" .
"live channel info playListName: ". $info->getPlayListName() . "\n");
/**
如果想查看一个频道历史推流记录可以调用getLiveChannelHistory。目前最多可以看到10次推流的记录
* Gets the historical pushing streaming records by calling getLiveChannelHistory. Now the max records to return is 10.
*/
$history = $ossClient->getLiveChannelHistory($bucket, "test_rtmp_live");
if (count($history->getLiveRecordList()) != 0)
@ -90,9 +96,9 @@ if (count($history->getLiveRecordList()) != 0)
}
/**
对于正在推流的频道调用get_live_channel_stat可以获得流的状态信息。
如果频道正在推流那么stat_result中的所有字段都有意义。
如果频道闲置或者处于“Disabled”状态那么status为“Idle”或“Disabled”其他字段无意义。
* Get the live channel's status by calling getLiveChannelStatus.
* If the live channel is receiving the pushing stream, all attributes in stat_result are valid.
* If the live channel is idle or disabled, then the status is idle or Disabled and other attributes have no meaning.
*/
$status = $ossClient->getLiveChannelStatus($bucket, "test_rtmp_live");
Common::println("bucket $bucket listLiveChannel:\n" .
@ -108,9 +114,9 @@ Common::println("bucket $bucket listLiveChannel:\n" .
"live channel status AdioCodec: ". $status->getAudioCodec() . "\n");
/**
* 如果希望利用直播推流产生的ts文件生成一个点播列表可以使用postVodPlaylist方法。
* 指定起始时间为当前时间减去60秒结束时间为当前时间这意味着将生成一个长度为60秒的点播视频。
* 播放列表指定为“vod_playlist.m3u8”也就是说这个接口调用成功之后会在OSS上生成一个名叫“vod_playlist.m3u8”的播放列表文件。
* If you want to generate a play url from the ts files generated from pushing streaming, call postVodPlayList.
* Specify the start time to 60 seconds before the current time and the end time to the current time, which means that a video of 60 seconds is generated.
* The playlist file is specified to “vod_playlist.m3u8”, which means that a palylist file named vod_playlist.m3u8 is created after the interface is called.
*/
$current_time = time();
$ossClient->postVodPlaylist($bucket,
@ -120,6 +126,6 @@ $ossClient->postVodPlaylist($bucket,
);
/**
* 如果一个直播频道已经不打算再使用了那么可以调用delete_live_channel来删除频道。
* Call delete_live_channel to delete a live channel if it will no longer be in used.
*/
$ossClient->deleteBucketLiveChannel($bucket, "test_rtmp_live");

View File

@ -9,27 +9,27 @@ $bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
//******************************* Simple usage ***************************************************************
/**
* 查看完整用法中的 "putObjectByRawApis"函数查看使用基础的分片上传api进行文件上传用户可以基于这个自行实现断点续传等功能
* See the putObjectByRawAPis usage in complete example to check out basic multipart upload APIs which can be used as resumable upload.
*/
// 使用分片上传接口上传文件, 接口会根据文件大小决定是使用普通上传还是分片上传
// Upload a file using the multipart upload interface, which determines to use simple upload or multipart upload based on the file size.
$ossClient->multiuploadFile($bucket, "file.php", __FILE__, array());
Common::println("local file " . __FILE__ . " is uploaded to the bucket $bucket, file.php");
// 上传本地目录到bucket内的targetdir子目录中
// Upload local directory's data into target dir
$ossClient->uploadDir($bucket, "targetdir", __DIR__);
Common::println("local dir " . __DIR__ . " is uploaded to the bucket $bucket, targetdir/");
// 列出当前未完成的分片上传
// List the incomplete multipart uploads
$listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, array());
//******************************* 完整用法参考下面函数 ****************************************************
//******************************* For complete usage, see the following functions ****************************************************
multiuploadFile($ossClient, $bucket);
putObjectByRawApis($ossClient, $bucket);
@ -37,10 +37,10 @@ uploadDir($ossClient, $bucket);
listMultipartUploads($ossClient, $bucket);
/**
* 通过multipart上传文件
* Upload files using multipart upload
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function multiuploadFile($ossClient, $bucket)
@ -60,17 +60,17 @@ function multiuploadFile($ossClient, $bucket)
}
/**
* 使用基本的api分阶段进行分片上传
* Use basic multipart upload for file upload.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @throws OssException
*/
function putObjectByRawApis($ossClient, $bucket)
{
$object = "test/multipart-test.txt";
/**
* step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id
* step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id
*/
try {
$uploadId = $ossClient->initiateMultipartUpload($bucket, $object);
@ -81,7 +81,7 @@ function putObjectByRawApis($ossClient, $bucket)
}
print(__FUNCTION__ . ": initiateMultipartUpload OK" . "\n");
/*
* step 2. 上传分片
* step 2. Upload parts
*/
$partSize = 10 * 1024 * 1024;
$uploadFile = __FILE__;
@ -104,7 +104,7 @@ function putObjectByRawApis($ossClient, $bucket)
$contentMd5 = OssUtil::getMd5SumForFile($uploadFile, $fromPos, $toPos);
$upOptions[$ossClient::OSS_CONTENT_MD5] = $contentMd5;
}
//2. 将每一分片上传到OSS
//2. Upload each part to OSS
try {
$responseUploadPart[] = $ossClient->uploadPart($bucket, $object, $uploadId, $upOptions);
} catch (OssException $e) {
@ -122,7 +122,7 @@ function putObjectByRawApis($ossClient, $bucket)
);
}
/**
* step 3. 完成上传
* step 3. Complete the upload
*/
try {
$ossClient->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts);
@ -135,10 +135,10 @@ function putObjectByRawApis($ossClient, $bucket)
}
/**
* 按照目录上传文件
* Upload by directories
*
* @param OssClient $ossClient OssClient
* @param string $bucket 存储空间名称
* @param string $bucket bucket name
*
*/
function uploadDir($ossClient, $bucket)
@ -156,7 +156,7 @@ function uploadDir($ossClient, $bucket)
}
/**
* 获取当前未完成的分片上传列表
* Get ongoing multipart uploads
*
* @param $ossClient OssClient
* @param $bucket string

View File

@ -7,9 +7,9 @@ use OSS\Core\OssException;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
//******************************* Simple usage ***************************************************************
// 简单上传变量的内容到oss文件
// Upload the in-memory string (hi, oss) to an OSS file
$result = $ossClient->putObject($bucket, "b.file", "hi, oss");
Common::println("b.file is created");
Common::println($result['x-oss-request-id']);
@ -17,7 +17,7 @@ Common::println($result['etag']);
Common::println($result['content-md5']);
Common::println($result['body']);
// 上传本地文件
// Uploads a local file to an OSS file
$result = $ossClient->uploadFile($bucket, "c.file", __FILE__);
Common::println("c.file is created");
Common::println("b.file is created");
@ -26,21 +26,21 @@ Common::println($result['etag']);
Common::println($result['content-md5']);
Common::println($result['body']);
// 下载object到本地变量
// Download an oss object as an in-memory variable
$content = $ossClient->getObject($bucket, "b.file");
Common::println("b.file is fetched, the content is: " . $content);
// 给object添加symlink
// Add a symlink to an object
$content = $ossClient->putSymlink($bucket, "test-symlink", "b.file");
Common::println("test-symlink is created");
Common::println($result['x-oss-request-id']);
Common::println($result['etag']);
// 获取symlink
// Get a symlink
$content = $ossClient->getSymlink($bucket, "test-symlink");
Common::println("test-symlink refer to : " . $content[OssClient::OSS_SYMLINK_TARGET]);
// 下载object到本地文件
// Download an object to a local file.
$options = array(
OssClient::OSS_FILE_DOWNLOAD => "./c.file.localcopy",
);
@ -48,26 +48,26 @@ $ossClient->getObject($bucket, "c.file", $options);
Common::println("b.file is fetched to the local file: c.file.localcopy");
Common::println("b.file is created");
// 拷贝object
// Copy an object
$result = $ossClient->copyObject($bucket, "c.file", $bucket, "c.file.copy");
Common::println("lastModifiedTime: " . $result[0]);
Common::println("ETag: " . $result[1]);
// 判断object是否存在
// Check whether an object exists
$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy");
Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no"));
// 删除object
// Delete an object
$result = $ossClient->deleteObject($bucket, "c.file.copy");
Common::println("c.file.copy is deleted");
Common::println("b.file is created");
Common::println($result['x-oss-request-id']);
// 判断object是否存在
// Check whether an object exists
$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy");
Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no"));
// 批量删除object
// Delete multiple objects in batch
$result = $ossClient->deleteObjects($bucket, array("b.file", "c.file"));
foreach($result as $object)
Common::println($object);
@ -75,7 +75,7 @@ foreach($result as $object)
sleep(2);
unlink("c.file.localcopy");
//******************************* 完整用法参考下面函数 ****************************************************
//******************************* For complete usage, see the following functions ****************************************************
listObjects($ossClient, $bucket);
listAllObjects($ossClient, $bucket);
@ -93,10 +93,10 @@ doesObjectExist($ossClient, $bucket);
getSymlink($ossClient, $bucket);
putSymlink($ossClient, $bucket);
/**
* 创建虚拟目录
* Create a 'virtual' folder
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function createObjectDir($ossClient, $bucket)
@ -112,12 +112,12 @@ function createObjectDir($ossClient, $bucket)
}
/**
* 把本地变量的内容到文件
* Upload in-memory data to oss
*
* 简单上传,上传指定变量的内存值作为object的内容
* Simple upload---upload specified in-memory data to an OSS object
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function putObject($ossClient, $bucket)
@ -137,10 +137,10 @@ function putObject($ossClient, $bucket)
/**
* 上传指定的本地文件内容
* Uploads a local file to OSS
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function uploadFile($ossClient, $bucket)
@ -160,11 +160,12 @@ function uploadFile($ossClient, $bucket)
}
/**
* 列出Bucket内所有目录和文件, 注意如果符合条件的文件数目超过设置的max-keys 用户需要使用返回的nextMarker作为入参通过
* 循环调用ListObjects得到所有的文件具体操作见下面的 listAllObjects 示例
* Lists all files and folders in the bucket.
* Note if there's more items than the max-keys specified, the caller needs to use the nextMarker returned as the value for the next call's maker paramter.
* Loop through all the items returned from ListObjects.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function listObjects($ossClient, $bucket)
@ -187,8 +188,8 @@ function listObjects($ossClient, $bucket)
return;
}
print(__FUNCTION__ . ": OK" . "\n");
$objectList = $listObjectInfo->getObjectList(); // 文件列表
$prefixList = $listObjectInfo->getPrefixList(); // 目录列表
$objectList = $listObjectInfo->getObjectList(); // object list
$prefixList = $listObjectInfo->getPrefixList(); // directory list
if (!empty($objectList)) {
print("objectList:\n");
foreach ($objectList as $objectInfo) {
@ -204,15 +205,15 @@ function listObjects($ossClient, $bucket)
}
/**
* 列出Bucket内所有目录和文件 根据返回的nextMarker循环得到所有Objects
* Lists all folders and files under the bucket. Use nextMarker repeatedly to get all objects.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function listAllObjects($ossClient, $bucket)
{
//构造dir下的文件和虚拟目录
// Create dir/obj 'folder' and put some files into it.
for ($i = 0; $i < 100; $i += 1) {
$ossClient->putObject($bucket, "dir/obj" . strval($i), "hi");
$ossClient->createObjectDir($bucket, "dir/obj" . strval($i));
@ -238,7 +239,7 @@ function listAllObjects($ossClient, $bucket)
printf($e->getMessage() . "\n");
return;
}
// 得到nextMarker从上一次listObjects读到的最后一个文件的下一个文件开始继续获取文件列表
// Get the nextMarker, and it would be used as the next call's marker parameter to resume from the last call
$nextMarker = $listObjectInfo->getNextMarker();
$listObject = $listObjectInfo->getObjectList();
$listPrefix = $listObjectInfo->getPrefixList();
@ -251,10 +252,10 @@ function listAllObjects($ossClient, $bucket)
}
/**
* 获取object的内容
* Get the content of an object.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getObject($ossClient, $bucket)
@ -277,10 +278,10 @@ function getObject($ossClient, $bucket)
}
/**
* put symlink
* Put symlink
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient The Instance of OssClient
* @param string $bucket bucket name
* @return null
*/
function putSymlink($ossClient, $bucket)
@ -305,10 +306,10 @@ function putSymlink($ossClient, $bucket)
}
/**
* 获取symlink
* Get symlink
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getSymlink($ossClient, $bucket)
@ -333,13 +334,13 @@ function getSymlink($ossClient, $bucket)
}
/**
* get_object_to_local_file
* Get_object_to_local_file
*
* 获取object
* 将object下载到指定的文件
* Get object
* Download object to a specified file.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getObjectToLocalFile($ossClient, $bucket)
@ -369,11 +370,11 @@ function getObjectToLocalFile($ossClient, $bucket)
}
/**
* 拷贝object
* 当目的object和源object完全相同时表示修改object的meta信息
* Copy object
* When the source object is same as the target one, copy operation will just update the metadata.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function copyObject($ossClient, $bucket)
@ -395,11 +396,11 @@ function copyObject($ossClient, $bucket)
}
/**
* 修改Object Meta
* 利用copyObject接口的特性当目的object和源object完全相同时表示修改object的meta信息
* Update Object Meta
* it leverages the feature of copyObject when the source object is just the target object, the metadata could be updated via copy
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function modifyMetaForObject($ossClient, $bucket)
@ -425,10 +426,10 @@ function modifyMetaForObject($ossClient, $bucket)
}
/**
* 获取object meta, 也就是getObjectMeta接口
* Get object meta, that is, getObjectMeta
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function getObjectMeta($ossClient, $bucket)
@ -452,10 +453,10 @@ function getObjectMeta($ossClient, $bucket)
}
/**
* 删除object
* Delete an object
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function deleteObject($ossClient, $bucket)
@ -473,10 +474,10 @@ function deleteObject($ossClient, $bucket)
/**
* 批量删除object
* Delete multiple objects in batch
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function deleteObjects($ossClient, $bucket)
@ -495,10 +496,10 @@ function deleteObjects($ossClient, $bucket)
}
/**
* 判断object是否存在
* Check whether an object exists
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
*/
function doesObjectExist($ossClient, $bucket)

View File

@ -9,5 +9,5 @@ require_once __DIR__ . '/BucketReferer.php';
require_once __DIR__ . '/BucketLogging.php';
require_once __DIR__ . '/BucketWebsite.php';
require_once __DIR__ . '/Signature.php';
require_once __DIR__ . '/Object.php';
require_once __DIR__ . '/Object1.php';
require_once __DIR__ . '/MultipartUpload.php';

View File

@ -10,33 +10,33 @@ $bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//******************************* 简单使用 ***************************************************************
//******************************* Simple Usage ***************************************************************
$ossClient->uploadFile($bucket, "a.file", __FILE__);
// 生成GetObject的签名url用户可以使用这个url直接在浏览器下载
// Generate a signed url for getting an object. The URL can be used in browser directly to download the file.
$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600);
Common::println($signedUrl);
// 生成用于putObject的签名URL用户可以直接用put方法使用这个url上传文件到 "a.file"
// Generate the signed url for putting an object. User can use put method with this url to upload a file to "a.file".
$signedUrl = $ossClient->signUrl($bucket, "a.file", "3600", "PUT");
Common::println($signedUrl);
// 生成从本地文件上传PutObject的签名url, 用户可以直接使用这个url把本地文件上传到 "a.file"
// Generate the signed url for putting an object from local file. The url can be used directly to upload the file to "a.file".
$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600, "PUT", array('Content-Type' => 'txt'));
Common::println($signedUrl);
//******************************* 完整用法参考下面函数 ****************************************************
//******************************* For complete usage, see the following functions ****************************************************
getSignedUrlForPuttingObject($ossClient, $bucket);
getSignedUrlForPuttingObjectFromFile($ossClient, $bucket);
getSignedUrlForGettingObject($ossClient, $bucket);
/**
* 生成GetObject的签名url,主要用于私有权限下的读访问控制
* Generate the signed url for getObject() to control read accesses under private privilege
*
* @param $ossClient OssClient OssClient实例
* @param $bucket string 存储空间名称
* @param $ossClient OssClient OssClient instance
* @param $bucket string bucket name
* @return null
*/
function getSignedUrlForGettingObject($ossClient, $bucket)
@ -52,7 +52,7 @@ function getSignedUrlForGettingObject($ossClient, $bucket)
}
print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");
/**
* 可以类似的代码来访问签名的URL也可以输入到浏览器中去访问
* Use similar code to access the object by url, or use browser to access the object.
*/
$request = new RequestCore($signedUrl);
$request->set_method('GET');
@ -67,10 +67,10 @@ function getSignedUrlForGettingObject($ossClient, $bucket)
}
/**
* 生成PutObject的签名url,主要用于私有权限下的写访问控制
* Generate the signed url for PutObject to control write accesses under private privilege.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @return null
* @throws OssException
*/
@ -105,11 +105,10 @@ function getSignedUrlForPuttingObject($ossClient, $bucket)
}
/**
* 生成PutObject的签名url,主要用于私有权限下的写访问控制, 用户可以利用生成的signedUrl
* 从文件上传文件
* Generate the signed url for PutObject's signed url. User could use the signed url to upload file directly.
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @param OssClient $ossClient OssClient instance
* @param string $bucket bucket name
* @throws OssException
*/
function getSignedUrlForPuttingObjectFromFile($ossClient, $bucket)

View File

@ -5,16 +5,17 @@ namespace OSS\Core;
/**
* Class MimeTypes
*
* 在上传文件的时候根据文件的缺省名得到其对应的Content-type
* The map of a file's extention name to its corresponding Content-Type value in the file upload request.
* If the file extention name is not predefined in this class, getMimetype() returns null.
*
* @package OSS\Core
*/
class MimeTypes
{
/**
* 根据文件名获取http协议header中的content-type应该填写的数据
* Get the content-type value of http header from the file's extension name.
*
* @param string $name 缺省名
* @param string $name Default file extension name.
* @return string content-type
*/
public static function getMimetype($name)

View File

@ -5,8 +5,8 @@ namespace OSS\Core;
/**
* Class OssException
*
* OssClient在使用的时候所抛出的异常用户在使用OssClient的时候要Try住相关代码
* try的Exception应该是OssException其中会得到相关异常原因
* This is the class that OSSClient is expected to thrown, which the caller needs to handle properly.
* It has the OSS specific errors which is useful for troubleshooting.
*
* @package OSS\Core
*/

View File

@ -5,7 +5,7 @@ namespace OSS\Core;
/**
* Class OssUtil
*
* Oss工具类主要供OssClient使用用户也可以使用本类进行返回结果的格式化
* Oss Util class for OssClient. The caller could use it for formating the result from OssClient.
*
* @package OSS
*/
@ -20,10 +20,10 @@ class OssUtil
const OSS_MIN_PART_SIZE = 102400; // 100KB
/**
* 生成query params
* Generate query params
*
* @param array $options 关联数组
* @return string 返回诸如 key1=value1&key2=value2
* @param array $options: a key-value pair array.
* @return string: the key-value list in the format such as key1=value1&key2=value2
*/
public static function toQueryString($options = array())
{
@ -38,7 +38,7 @@ class OssUtil
}
/**
* 转义字符替换
* Html encoding '<', '>', '&', '\', '"' in subject parameter.
*
* @param string $subject
* @return string
@ -51,7 +51,7 @@ class OssUtil
}
/**
* 检查是否是中文编码
* Check whether the string includes any chinese character
*
* @param $str
* @return int
@ -62,10 +62,10 @@ class OssUtil
}
/**
* 检测是否GB2312编码
* Checks if the string is encoded by GB2312.
*
* @param string $str
* @return boolean false UTF-8编码 TRUE GB2312编码
* @return boolean false UTF-8 encoding TRUE GB2312 encoding
*/
public static function isGb2312($str)
{
@ -87,7 +87,7 @@ class OssUtil
}
/**
* 检测是否GBK编码
* Checks if the string is encoded by GBK
*
* @param string $str
* @param boolean $gbk
@ -114,13 +114,13 @@ class OssUtil
}
/**
* 检验bucket名称是否合法
* bucket的命名规范:
* 1. 只能包括小写字母,数字
* 2. 必须以小写字母或者数字开头
* 3. 长度必须在3-63字节之间
* Checks if the bucket name is valid
* bucket naming rules
* 1. Can only include lowercase letters, numbers, or dashes
* 2. Must start and end with lowercase letters or numbers
* 3. Must be within a length from 3 to 63 bytes.
*
* @param string $bucket Bucket名称
* @param string $bucket Bucket name
* @return boolean
*/
public static function validateBucket($bucket)
@ -133,11 +133,11 @@ class OssUtil
}
/**
* 检验object名称是否合法
* object命名规范:
* 1. 规则长度必须在1-1023字节之间
* 2. 使用UTF-8编码
* 3. 不能以 "/" "\\"开头
* Checks if object name is valid
* object naming rules:
* 1. Must be within a length from 1 to 1023 bytes
* 2. Cannot start with '/' or '\\'.
* 3. Must be encoded in UTF-8.
*
* @param string $object Object名称
* @return boolean
@ -155,7 +155,7 @@ class OssUtil
/**
* 判断字符串$str是不是以$findMe开始
* Checks if $str starts with $findMe
*
* @param string $str
* @param string $findMe
@ -170,8 +170,9 @@ class OssUtil
}
}
/**
* 生成createBucketXmlBody接口的xml消息
* Generate the xml message of createBucketXmlBody.
*
* @param string $storageClass
* @return string
@ -184,7 +185,7 @@ class OssUtil
}
/**
* 检验$options
* validate $options
*
* @param array $options
* @throws OssException
@ -199,7 +200,7 @@ class OssUtil
}
/**
* 检查上传文件的内容是否合法
* check whether the Content is valid.
*
* @param $content string
* @throws OssException
@ -212,7 +213,7 @@ class OssUtil
}
/**
* 校验BUCKET/OBJECT/OBJECT GROUP是否为空
* Check if BUCKET/OBJECT/OBJECT GROUP is empty.
*
* @param string $name
* @param string $errMsg
@ -227,7 +228,7 @@ class OssUtil
}
/**
* 仅供测试使用的接口,请勿使用
* This is a method for test only. DO NOT USE.
*
* @param $filename
* @param $size
@ -268,7 +269,7 @@ BBB;
}
/**
* 得到文件的md5编码
* Get MD5 of the file.
*
* @param $filename
* @param $from_pos
@ -318,7 +319,7 @@ BBB;
}
/**
* 检测是否windows系统因为windows系统默认编码为GBK
* Check if the OS is Windows. The default encoding in Windows is GBK.
*
* @return bool
*/
@ -328,7 +329,9 @@ BBB;
}
/**
* 主要是由于windows系统编码是gbk遇到中文时候如果不进行转换处理会出现找不到文件的问题
* Encodes the file path from GBK to UTF-8.
* The default encoding in Windows is GBK.
* And if the file path is in Chinese, the file would not be found without the transcoding to UTF-8.
*
* @param $file_path
* @return string
@ -342,9 +345,9 @@ BBB;
}
/**
* 判断用户输入的endpoint是否是 xxx.xxx.xxx.xxx:port 或者 xxx.xxx.xxx.xxx的ip格式
* Check if the endpoint is in the IPv4 format, such as xxx.xxx.xxx.xxx:port or xxx.xxx.xxx.xxx.
*
* @param string $endpoint 需要做判断的endpoint
* @param string $endpoint The endpoint to check.
* @return boolean
*/
public static function isIPFormat($endpoint)
@ -360,7 +363,44 @@ BBB;
}
/**
* 生成DeleteMultiObjects接口的xml消息
* Get the host:port from endpoint.
*
* @param string $endpoint the endpoint.
* @return boolean
*/
public static function getHostPortFromEndpoint($endpoint)
{
$str = $endpoint;
$pos = strpos($str, "://");
if ($pos !== false) {
$str = substr($str, $pos+3);
}
$pos = strpos($str, '#');
if ($pos !== false) {
$str = substr($str, 0, $pos);
}
$pos = strpos($str, '?');
if ($pos !== false) {
$str = substr($str, 0, $pos);
}
$pos = strpos($str, '/');
if ($pos !== false) {
$str = substr($str, 0, $pos);
}
$pos = strpos($str, '@');
if ($pos !== false) {
$str = substr($str, $pos+1);
}
return $str;
}
/**
* Generate the xml message of DeleteMultiObjects.
*
* @param string[] $objects
* @param bool $quiet
@ -379,7 +419,7 @@ BBB;
}
/**
* 生成CompleteMultipartUpload接口的xml消息
* Generate the xml message of CompleteMultipartUpload.
*
* @param array[] $listParts
* @return string
@ -396,7 +436,7 @@ BBB;
}
/**
* 读取目录
* Read the directory, return a associative array in which the MD5 is the named key and the <path,filanme> is the value.
*
* @param string $dir
* @param string $exclude

View File

@ -3,7 +3,7 @@ namespace OSS\Http;
/**
* Handles all HTTP requests using cURL and manages the responses.
* Handle all HTTP requests using cURL and manages the responses.
*
* @version 2011.06.07
* @copyright 2006-2011 Ryan Parman
@ -75,7 +75,7 @@ class RequestCore
public $method;
/**
* Stores the proxy settings to use for the request.
* Store the proxy settings to use for the request.
*/
public $proxy = null;
@ -170,14 +170,14 @@ class RequestCore
public $registered_streaming_write_callback = null;
/**
* 请求超时时间, 默认是5184000秒6天
* The request timeout time, which is 5,184,000 seconds,that is, 6 days by default
*
* @var int
*/
public $timeout = 5184000;
/**
* 连接超时时间默认是10秒
* The connection timeout time, which is 10 seconds by default
*
* @var int
*/
@ -216,7 +216,7 @@ class RequestCore
// CONSTRUCTOR/DESTRUCTOR
/**
* Constructs a new instance of this class.
* Construct a new instance of this class.
*
* @param string $url (Optional) The URL to request or service endpoint to query.
* @param string $proxy (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port`
@ -249,7 +249,7 @@ class RequestCore
}
/**
* Destructs the instance. Closes opened file handles.
* Destruct the instance. Closes opened file handles.
*
* @return $this A reference to the current instance.
*/
@ -271,7 +271,7 @@ class RequestCore
// REQUEST METHODS
/**
* Sets the credentials to use for authentication.
* Set the credentials to use for authentication.
*
* @param string $user (Required) The username to authenticate with.
* @param string $pass (Required) The password to authenticate with.
@ -285,7 +285,7 @@ class RequestCore
}
/**
* Adds a custom HTTP header to the cURL request.
* Add a custom HTTP header to the cURL request.
*
* @param string $key (Required) The custom HTTP header to set.
* @param mixed $value (Required) The value to assign to the custom HTTP header.
@ -298,7 +298,7 @@ class RequestCore
}
/**
* Removes an HTTP header from the cURL request.
* Remove an HTTP header from the cURL request.
*
* @param string $key (Required) The custom HTTP header to set.
* @return $this A reference to the current instance.
@ -324,7 +324,7 @@ class RequestCore
}
/**
* Sets a custom useragent string for the class.
* Set a custom useragent string for the class.
*
* @param string $ua (Required) The useragent string to use.
* @return $this A reference to the current instance.
@ -373,7 +373,7 @@ class RequestCore
}
/**
* Sets the length in bytes to read from the stream while streaming up.
* Set the length in bytes to read from the stream while streaming up.
*
* @param integer $size (Required) The length in bytes to read from the stream.
* @return $this A reference to the current instance.
@ -386,7 +386,7 @@ class RequestCore
}
/**
* Sets the resource to read from while streaming up. Reads the stream from its current position until
* Set the resource to read from while streaming up. Reads the stream from its current position until
* EOF or `$size` bytes have been read. If `$size` is not given it will be determined by <php:fstat()> and
* <php:ftell()>.
*
@ -414,7 +414,7 @@ class RequestCore
}
/**
* Sets the file to read from while streaming up.
* Set the file to read from while streaming up.
*
* @param string $location (Required) The readable location to read from.
* @return $this A reference to the current instance.
@ -428,7 +428,7 @@ class RequestCore
}
/**
* Sets the resource to write to while streaming down.
* Set the resource to write to while streaming down.
*
* @param resource $resource (Required) The writeable resource to write to.
* @return $this A reference to the current instance.
@ -441,7 +441,7 @@ class RequestCore
}
/**
* Sets the file to write to while streaming down.
* Set the file to write to while streaming down.
*
* @param string $location (Required) The writeable location to write to.
* @return $this A reference to the current instance.
@ -631,7 +631,7 @@ class RequestCore
}
/**
* Prepares and adds the details of the cURL request. This can be passed along to a <php:curl_multi_exec()>
* Prepare and adds the details of the cURL request. This can be passed along to a <php:curl_multi_exec()>
* function.
*
* @return resource The handle for the cURL object.
@ -685,7 +685,6 @@ class RequestCore
// Enable a proxy connection if requested.
if ($this->proxy) {
$host = $this->proxy['host'];
$host .= ($this->proxy['port']) ? ':' . $this->proxy['port'] : '';
curl_setopt($curl_handle, CURLOPT_PROXY, $host);
@ -830,7 +829,7 @@ class RequestCore
}
/**
* Sends the request, calling necessary utility functions to update built-in properties.
* Send the request, calling necessary utility functions to update built-in properties.
*
* @param boolean $parse (Optional) Whether to parse the response with ResponseCore or not.
* @return string The resulting unparsed data from the request.

View File

@ -8,25 +8,25 @@ namespace OSS\Http;
class ResponseCore
{
/**
* Stores the HTTP header information.
* Store the HTTP header information.
*/
public $header;
/**
* Stores the SimpleXML response.
* Store the SimpleXML response.
*/
public $body;
/**
* Stores the HTTP response code.
* Store the HTTP response code.
*/
public $status;
/**
* Constructs a new instance of this class.
* Construct a new instance of this class.
*
* @param array $header (Required) Associative array of HTTP headers (typically returned by <RequestCore::get_response_header()>).
* @param string $body (Required) XML-formatted response from AWS.
* @param string $body (Required) XML-formatted response from OSS.
* @param integer $status (Optional) HTTP response status code from the request.
* @return Mixed Contains an <php:array> `header` property (HTTP headers as an associative array), a <php:SimpleXMLElement> or <php:string> `body` property, and an <php:integer> `status` code.
*/

View File

@ -4,7 +4,7 @@ namespace OSS\Model;
/**
* Bucket信息ListBuckets接口返回数据
* Bucket information class. This is the type of element in BucketListInfo's
*
* Class BucketInfo
* @package OSS\Model
@ -26,7 +26,7 @@ class BucketInfo
}
/**
* 得到bucket所在的region
* Get bucket location
*
* @return string
*/
@ -36,7 +36,7 @@ class BucketInfo
}
/**
* 得到bucket的名称
* Get bucket name
*
* @return string
*/
@ -46,7 +46,7 @@ class BucketInfo
}
/**
* 得到bucket的创建时间
* Get bucket creation time.
*
* @return string
*/
@ -56,20 +56,20 @@ class BucketInfo
}
/**
* bucket所在的region
* bucket region
*
* @var string
*/
private $location;
/**
* bucket的名称
* bucket name
*
* @var string
*/
private $name;
/**
* bucket的创建事件
* bucket creation time
*
* @var string
*/

View File

@ -5,7 +5,7 @@ namespace OSS\Model;
/**
* Class BucketListInfo
*
* ListBuckets接口返回的数据类型
* It's the type of return value of ListBuckets.
*
* @package OSS\Model
*/
@ -21,7 +21,7 @@ class BucketListInfo
}
/**
* 得到BucketInfo列表
* Get the BucketInfo list
*
* @return BucketInfo[]
*/
@ -31,7 +31,7 @@ class BucketListInfo
}
/**
* BucketInfo信息列表
* BucketInfo list
*
* @var array
*/

View File

@ -22,7 +22,7 @@ class CorsConfig implements XmlConfig
}
/**
* 得到CorsRule列表
* Get CorsRule list
*
* @return CorsRule[]
*/
@ -33,7 +33,7 @@ class CorsConfig implements XmlConfig
/**
* 添加一条CorsRule
* Add a new CorsRule
*
* @param CorsRule $rule
* @throws OssException
@ -47,7 +47,7 @@ class CorsConfig implements XmlConfig
}
/**
* 从xml数据中解析出CorsConfig
* Parse CorsConfig from the xml.
*
* @param string $strXml
* @throws OssException
@ -78,7 +78,7 @@ class CorsConfig implements XmlConfig
}
/**
* 生成xml字符串
* Serialize the object into xml string.
*
* @return string
*/
@ -105,7 +105,7 @@ class CorsConfig implements XmlConfig
const OSS_MAX_RULES = 10;
/**
* orsRule列表
* CorsRule list
*
* @var CorsRule[]
*/

View File

@ -13,7 +13,7 @@ use OSS\Core\OssException;
class CorsRule
{
/**
* Rule中增加一条allowedOrigin
* Add an allowedOrigin rule
*
* @param string $allowedOrigin
*/
@ -25,7 +25,7 @@ class CorsRule
}
/**
* Rule中增加一条allowedMethod
* Add an allowedMethod rule
*
* @param string $allowedMethod
*/
@ -37,7 +37,7 @@ class CorsRule
}
/**
* Rule中增加一条allowedHeader
* Add an allowedHeader rule
*
* @param string $allowedHeader
*/
@ -49,7 +49,7 @@ class CorsRule
}
/**
* Rule中增加一条exposeHeader
* Add an exposeHeader rule
*
* @param string $exposeHeader
*/
@ -77,7 +77,7 @@ class CorsRule
}
/**
* 得到AllowedHeaders列表
* Get the AllowedHeaders list
*
* @return string[]
*/
@ -87,7 +87,7 @@ class CorsRule
}
/**
* 得到AllowedOrigins列表
* Get the AllowedOrigins list
*
* @return string[]
*/
@ -97,7 +97,7 @@ class CorsRule
}
/**
* 得到AllowedMethods列表
* Get the AllowedMethods list
*
* @return string[]
*/
@ -107,7 +107,7 @@ class CorsRule
}
/**
* 得到ExposeHeaders列表
* Get the ExposeHeaders list
*
* @return string[]
*/
@ -117,7 +117,7 @@ class CorsRule
}
/**
* 根据提供的xmlRule 把this按照一定的规则插入到$xmlRule中
* Serialize all the rules into the xml represented by parameter $xmlRule
*
* @param \SimpleXMLElement $xmlRule
* @throws OssException

View File

@ -71,7 +71,7 @@ class LifecycleAction
}
/**
* appendToXml 把actions插入到xml中
* Use appendToXml to insert actions into xml.
*
* @param \SimpleXMLElement $xmlRule
*/

View File

@ -13,7 +13,7 @@ use OSS\Core\OssException;
class LifecycleConfig implements XmlConfig
{
/**
* 从xml数据中解析出LifecycleConfig
* Parse the xml into this object.
*
* @param string $strXml
* @throws OssException
@ -48,7 +48,7 @@ class LifecycleConfig implements XmlConfig
/**
* 生成xml字符串
* Serialize the object to xml
*
* @return string
*/
@ -65,7 +65,7 @@ class LifecycleConfig implements XmlConfig
/**
*
* 添加LifecycleRule
* Add a LifecycleRule
*
* @param LifecycleRule $lifecycleRule
* @throws OssException
@ -79,7 +79,7 @@ class LifecycleConfig implements XmlConfig
}
/**
* 将配置转换成字符串,便于用户查看
* Serialize the object into xml string.
*
* @return string
*/
@ -89,7 +89,7 @@ class LifecycleConfig implements XmlConfig
}
/**
* 得到所有的生命周期规则
* Get all lifecycle rules.
*
* @return LifecycleRule[]
*/

View File

@ -12,7 +12,7 @@ namespace OSS\Model;
class LifecycleRule
{
/**
* 得到规则ID
* Get Id
*
* @return string
*/
@ -22,7 +22,7 @@ class LifecycleRule
}
/**
* @param string $id 规则ID
* @param string $id Rule Id
*/
public function setId($id)
{
@ -30,7 +30,7 @@ class LifecycleRule
}
/**
* 得到文件前缀
* Get a file prefix
*
* @return string
*/
@ -40,9 +40,9 @@ class LifecycleRule
}
/**
* 设置文件前缀
* Set a file prefix
*
* @param string $prefix 文件前缀
* @param string $prefix The file prefix
*/
public function setPrefix($prefix)
{
@ -50,7 +50,7 @@ class LifecycleRule
}
/**
* Lifecycle规则的状态
* Get Lifecycle status
*
* @return string
*/
@ -60,7 +60,7 @@ class LifecycleRule
}
/**
* 设置Lifecycle规则状态
* Set Lifecycle status
*
* @param string $status
*/
@ -90,9 +90,9 @@ class LifecycleRule
/**
* LifecycleRule constructor.
*
* @param string $id 规则ID
* @param string $prefix 文件前缀
* @param string $status 规则状态,可选[self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED]
* @param string $id rule Id
* @param string $prefix File prefix
* @param string $status Rule status, which has the following valid values: [self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED]
* @param LifecycleAction[] $actions
*/
public function __construct($id, $prefix, $status, $actions)

View File

@ -5,7 +5,7 @@ namespace OSS\Model;
/**
* Class LiveChannelListInfo
*
* ListBucketLiveChannels接口返回数据
* The data returned by ListBucketLiveChannels
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html

View File

@ -42,7 +42,7 @@ class LoggingConfig implements XmlConfig
}
/**
* 序列化成xml字符串
* Serialize to xml string
*
*/
public function serializeToXml()

View File

@ -6,11 +6,11 @@ namespace OSS\Model;
*
* Class ObjectInfo
*
* listObjects接口中返回的Object列表中的类
* The element type of ObjectListInfo, which is the return value type of listObjects
*
* listObjects接口返回数据中包含两个Array
* 一个是拿到的Object列表【可以理解成对应文件系统中的文件列表】
* 一个是拿到的Prefix列表【可以理解成对应文件系统中的目录列表】
* The return value of listObjects includes two arrays
* One is the returned ObjectListInfo, which is similar to a file list in a file system.
* The other is the returned prefix list, which is similar to a folder list in a file system.
*
* @package OSS\Model
*/

View File

@ -5,7 +5,7 @@ namespace OSS\Model;
/**
* Class ObjectListInfo
*
* ListObjects接口返回数据
* The class of return value of ListObjects
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
@ -87,7 +87,7 @@ class ObjectListInfo
}
/**
* 返回ListObjects接口返回数据中的ObjectInfo列表
* Get the ObjectInfo list.
*
* @return ObjectInfo[]
*/
@ -97,7 +97,7 @@ class ObjectListInfo
}
/**
* 返回ListObjects接口返回数据中的PrefixInfo列表
* Get the PrefixInfo list
*
* @return PrefixInfo[]
*/

View File

@ -5,10 +5,10 @@ namespace OSS\Model;
/**
* Class PrefixInfo
*
* listObjects接口中返回的Prefix列表中的类
* listObjects接口返回数据中包含两个Array:
* 一个是拿到的Object列表【可以理解成对应文件系统中的文件列表
* 一个是拿到的Prefix列表【可以理解成对应文件系统中的目录列表
* ListObjects return Prefix list of classes
* The returned data contains two arrays
* One is to get the list of objects【Can be understood as the corresponding file system file list
* One is to get Prefix list【Can be understood as the corresponding file system directory list
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html

View File

@ -29,7 +29,7 @@ class RefererConfig implements XmlConfig
/**
* 把RefererConfig序列化成xml
* serialize the RefererConfig object into xml string
*
* @return string
*/

View File

@ -29,7 +29,7 @@ class StorageCapacityConfig implements XmlConfig
}
/**
* 把StorageCapacityConfig序列化成xml
* Serialize StorageCapacityConfig into xml
*
* @return string
*/

View File

@ -5,7 +5,7 @@ namespace OSS\Model;
/**
* Class UploadInfo
*
* ListMultipartUpload接口得到的UploadInfo
* The return value of ListMultipartUpload
*
* @package OSS\Model
*/

View File

@ -40,7 +40,7 @@ class WebsiteConfig implements XmlConfig
}
/**
* 把WebsiteConfig序列化成xml
* Serialize the WebsiteConfig object into xml string.
*
* @return string
* @throws OssException

View File

@ -10,7 +10,7 @@ interface XmlConfig
{
/**
* 接口定义实现此接口的类都需要实现从xml数据解析的函数
* Interface method: Parse the object from the xml.
*
* @param string $strXml
* @return null
@ -18,7 +18,7 @@ interface XmlConfig
public function parseFromXml($strXml);
/**
* 接口定义实现此接口的类都需要实现把子类序列化成xml字符串的接口
* Interface method: Serialize the object into xml.
*
* @return string
*/

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,7 @@ namespace OSS\Result;
use OSS\Core\OssException;
/**
* Class AclResult getBucketAcl接口返回结果类封装了
* 返回的xml数据的解析
* The type of the return value of getBucketAcl, it wraps the data parsed from xml.
*
* @package OSS\Result
*/

View File

@ -11,7 +11,7 @@ use OSS\Core\OssException;
class AppendResult extends Result
{
/**
* 结果中part的next-append-position
* Get the value of next-append-position from append's response headers
*
* @return int
* @throws OssException

View File

@ -3,8 +3,7 @@
namespace OSS\Result;
/**
* Class ExistResult 检查bucket和object是否存在的返回结果
* 根据返回response的http status判断
* Class ExistResult checks if bucket or object exists, according to the http status in response headers.
* @package OSS\Result
*/
class ExistResult extends Result
@ -18,8 +17,8 @@ class ExistResult extends Result
}
/**
* 根据返回http状态码判断[200-299]即认为是OK, 判断是否存在的接口404也认为是一种
* 有效响应
* Check if the response status is OK according to the http status code.
* [200-299]: OK; [404]: Not found. It means the object or bucket is not found--it's a valid response too.
*
* @return bool
*/

View File

@ -18,8 +18,7 @@ class GetCorsResult extends Result
}
/**
* 根据返回http状态码判断[200-299]即认为是OK, 获取bucket相关配置的接口404也认为是一种
* 有效响应
* Check if the response is OK, according to the http status. [200-299]:OK, the Cors config could be got; [404]: not found--no Cors config.
*
* @return bool
*/

View File

@ -12,7 +12,7 @@ use OSS\Model\LifecycleConfig;
class GetLifecycleResult extends Result
{
/**
* 解析Lifestyle数据
* Parse the LifecycleConfig object from the response
*
* @return LifecycleConfig
*/
@ -25,8 +25,8 @@ class GetLifecycleResult extends Result
}
/**
* 根据返回http状态码判断[200-299]即认为是OK, 获取bucket相关配置的接口404也认为是一种
* 有效响应
* Check if the response is OK according to the http status.
* [200-299]: OK, and the LifecycleConfig could be got; [404] The Life cycle config is not found.
*
* @return bool
*/
@ -38,4 +38,4 @@ class GetLifecycleResult extends Result
}
return false;
}
}
}

View File

@ -4,8 +4,8 @@ namespace OSS\Result;
use OSS\Core\OssException;
/**
* Class GetLocationResult getBucketLocation接口返回结果类,封装了
* 返回的xml数据的解析
* Class GetLocationResult getBucketLocation interface returns the result class, encapsulated
* The returned xml data is parsed
*
* @package OSS\Result
*/

View File

@ -12,7 +12,7 @@ use OSS\Model\LoggingConfig;
class GetLoggingResult extends Result
{
/**
* 解析LoggingConfig数据
* Parse LoggingConfig data
*
* @return LoggingConfig
*/
@ -25,8 +25,8 @@ class GetLoggingResult extends Result
}
/**
* 根据返回http状态码判断[200-299]即认为是OK, 获取bucket相关配置的接口404也认为是一种
* 有效响应
* Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface,
* 404 is also considered a valid response
*
* @return bool
*/

View File

@ -12,7 +12,7 @@ use OSS\Model\RefererConfig;
class GetRefererResult extends Result
{
/**
* 解析RefererConfig数据
* Parse RefererConfig data
*
* @return RefererConfig
*/
@ -25,8 +25,8 @@ class GetRefererResult extends Result
}
/**
* 根据返回http状态码判断[200-299]即认为是OK, 获取bucket相关配置的接口404也认为是一种
* 有效响应
* Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface,
* 404 is also considered a valid response
*
* @return bool
*/

View File

@ -5,8 +5,8 @@ namespace OSS\Result;
use OSS\Core\OssException;
/**
* Class AclResult getBucketAcl接口返回结果类封装了
* 返回的xml数据的解析
* Class AclResult GetBucketAcl interface returns the result class, encapsulated
* The returned xml data is parsed
*
* @package OSS\Result
*/

View File

@ -11,7 +11,7 @@ use OSS\Model\WebsiteConfig;
class GetWebsiteResult extends Result
{
/**
* 解析WebsiteConfig数据
* Parse WebsiteConfig data
*
* @return WebsiteConfig
*/
@ -24,8 +24,8 @@ class GetWebsiteResult extends Result
}
/**
* 根据返回http状态码判断[200-299]即认为是OK, 获取bucket相关配置的接口404也认为是一种
* 有效响应
* Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface,
* 404 is also considered a valid response
*
* @return bool
*/

View File

@ -11,7 +11,7 @@ namespace OSS\Result;
class HeaderResult extends Result
{
/**
* 把返回的ResponseCore中的header作为返回数据
* The returned ResponseCore header is used as the return data
*
* @return array
*/

View File

@ -12,7 +12,7 @@ use OSS\Core\OssException;
class InitiateMultipartUploadResult extends Result
{
/**
* 结果中获取uploadId并返回
* Get uploadId in result and return
*
* @throws OssException
* @return string

View File

@ -14,7 +14,7 @@ use OSS\Model\UploadInfo;
class ListMultipartUploadResult extends Result
{
/**
* 解析从ListMultipartUpload接口的返回数据
* Parse the return data from the ListMultipartUpload interface
*
* @return ListMultipartUploadInfo
*/

View File

@ -14,7 +14,7 @@ use OSS\Model\PrefixInfo;
class ListObjectsResult extends Result
{
/**
* 解析ListObjects接口返回的xml数据
* Parse the xml data returned by the ListObjects interface
*
* return ObjectListInfo
*/

View File

@ -13,7 +13,7 @@ use OSS\Model\PartInfo;
class ListPartsResult extends Result
{
/**
* 解析ListParts接口返回的xml数据
* Parse the xml data returned by the ListParts interface
*
* @return ListPartsInfo
*/

View File

@ -7,8 +7,8 @@ use OSS\Http\ResponseCore;
/**
* Class Result, 操作结果类的基类,不同的请求在处理返回数据的时候有不同的逻辑,
* 具体的解析逻辑推迟到子类实现
* Class Result, The result class of The operation of the base class, different requests in dealing with the return of data have different logic,
* The specific parsing logic postponed to subclass implementation
*
* @package OSS\Model
*/
@ -29,7 +29,7 @@ abstract class Result
}
/**
* 获取requestId
* Get requestId
*
* @return string
*/
@ -46,7 +46,7 @@ abstract class Result
}
/**
* 得到返回数据,不同的请求返回数据格式不同
* Get the returned data, different request returns the data format is different
*
* $return mixed
*/
@ -56,14 +56,14 @@ abstract class Result
}
/**
* 由子类实现,不同的请求返回数据有不同的解析逻辑,由子类实现
* Subclass implementation, different requests return data has different analytical logic, implemented by subclasses
*
* @return mixed
*/
abstract protected function parseDataFromResponse();
/**
* 操作是否成功
* Whether the operation is successful
*
* @return mixed
*/
@ -99,7 +99,7 @@ abstract class Result
}
/**
* 尝试从body中获取错误Message
* Try to get the error message from body
*
* @param $body
* @return string
@ -117,7 +117,7 @@ abstract class Result
}
/**
* 尝试从body中获取错误Code
* Try to get the error Code from body
*
* @param $body
* @return string
@ -135,7 +135,7 @@ abstract class Result
}
/**
* 根据返回http状态码判断[200-299]即认为是OK
* Judging from the return http status code, [200-299] that is OK
*
* @return bool
*/
@ -149,7 +149,7 @@ abstract class Result
}
/**
* 返回原始的返回数据
* Return the original return data
*
* @return ResponseCore
*/
@ -159,15 +159,15 @@ abstract class Result
}
/**
* 标示请求是否成功
* Indicate whether the request is successful
*/
protected $isOk = false;
/**
* 由子类解析过的数据
* Data parsed by subclasses
*/
protected $parsedData = null;
/**
* 存放auth函数返回的原始Response
* Store the original Response returned by the auth function
*
* @var ResponseCore
*/

Some files were not shown because too many files have changed in this diff Show More