Update sdk

pull/6/head
sy-records 2020-12-13 10:53:24 +08:00
parent e91742b194
commit 47e1012b69
81 changed files with 7471 additions and 1212 deletions

16
sdk/composer.lock generated
View File

@ -8,16 +8,16 @@
"packages": [ "packages": [
{ {
"name": "aliyuncs/oss-sdk-php", "name": "aliyuncs/oss-sdk-php",
"version": "v2.3.1", "version": "v2.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aliyun/aliyun-oss-php-sdk.git", "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
"reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a" "reference": "492866331b7bafaac09506cf42f351b7e9e63766"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/053d7ba9e798e4c09b9c5c1edab153d25ea9643a", "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/492866331b7bafaac09506cf42f351b7e9e63766",
"reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a", "reference": "492866331b7bafaac09506cf42f351b7e9e63766",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -51,7 +51,11 @@
], ],
"description": "Aliyun OSS SDK for PHP", "description": "Aliyun OSS SDK for PHP",
"homepage": "http://www.aliyun.com/product/oss/", "homepage": "http://www.aliyun.com/product/oss/",
"time": "2019-11-15T11:05:42+00:00" "support": {
"issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues",
"source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.4.1"
},
"time": "2020-09-29T06:23:57+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],
@ -62,5 +66,5 @@
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "1.1.0" "plugin-api-version": "2.0.0"
} }

View File

@ -1,97 +1,123 @@
# ChangeLog - Aliyun OSS SDK for PHP # ChangeLog - Aliyun OSS SDK for PHP
## v2.3.1 / 2019-011-15 ## v2.4.1 / 2020-09-29
* Fixed: the getBucketPolicy bug.
* translate chinese comments into english
* Added: endpoint validity check
## v2.4.0 / 2020-08-31
## v2.3.0 / 2018-01-05
* Added: disable Expect: 100-continue
* Fixed: putObject support creating empty files * Added: support getBucketInfo
* Fixed: createBucket support IA/Archive * Added: support getBucketStat
* Added: support restoreObject * Added: support bucket policy
* Added: support the Symlink feature * Added: support bucket encryption
* Added: support getBucketLocation * Added: support bucket tagging
* Added: support getBucketMeta * Added: support bucket worm
* Added: support proxy server Proxy * Added: support versioning
* Added: support request payment
## v2.2.4 / 2017-04-25 * Added: support object tagging
* Added: support code archive
* Fixed getObject to local file bug * Added: support process object
* Added: support traffic limit paramter
## v2.2.3 / 2017-04-14 * Added: support upload object from file handle
* Added: support getSimplifiedObjectMeta
* Fixed md5 check * Fixed: the object name can not be '0' stirng.
* Update: endpoint validity check
## v2.2.2 / 2017-01-18 * Update: add new pre-signed url api
* Resolve to run the connection number and memory bug on php7
## v2.3.1 / 2019-01-15
## v2.2.1 / 2016-12-01
* translate chinese comments into english
* No HTTP curl is allowed to automatically populate accept-encoding * Added: endpoint validity check
## v2.2.0 / 2016-11-22 ## v2.3.0 / 2018-01-05
* Fixed PutObject/CompleteMultipartUpload return values(#26) * Fixed: putObject support creating empty files
* Fixed: createBucket support IA/Archive
## v2.1.0 / 2016-11-12 * Added: support restoreObject
* Added: support the Symlink feature
* Added[RTMP](https://help.aliyun.com/document_detail/44297.html)interface * Added: support getBucketLocation
* Add support[image service](https://help.aliyun.com/document_detail/44686.html) * Added: support getBucketMeta
* Added: support proxy server Proxy
## v2.0.7 / 2016-06-17
## v2.2.4 / 2017-04-25
* Support append object
* Fixed getObject to local file bug
## v2.0.6
## v2.2.3 / 2017-04-14
* Trim access key id/secret and endpoint
* Refine tests and setup travis CI * Fixed md5 check
## v2.0.5 ## v2.2.2 / 2017-01-18
* Added Add/Delete/Get BucketCname interface * Resolve to run the connection number and memory bug on php7
## v2.0.4 ## v2.2.1 / 2016-12-01
* Added Put/Get Object Acl interface * No HTTP curl is allowed to automatically populate accept-encoding
## v2.0.3 ## v2.2.0 / 2016-11-22
* Fixing the constants in Util is defined in a PHP version that is less than 5.6. * Fixed PutObject/CompleteMultipartUpload return values(#26)
## v2.0.2 ## v2.1.0 / 2016-11-12
* The problem of content-type cannot be specified when restoring multipart uploads * 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.1
## v2.0.7 / 2016-06-17
* Increase the ListObjects/ListMultipartUploads special characters
* Provides the interface to get the details of the OssException * Support append object
## v2.0.6
## 2015.11.25
* Trim access key id/secret and endpoint
* **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.** * Refine tests and setup travis CI
## Modify the content ## v2.0.5
* PHP 5.2 is no longer supported * Added Add/Delete/Get BucketCname interface
### Add the cotent ## v2.0.4
* Introduce namespace * Added Put/Get Object Acl interface
* Interface naming and modification, using hump naming
* The interface is modified, and the common parameters are extracted from the Options parameter. ## v2.0.3
* 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 * Fixing the constants in Util is defined in a PHP version that is less than 5.6.
* The Endpoint address that support CNAME and IP formats
* Rearrange the sample file organization structure and use function to organize the function points ## v2.0.2
* Add an interface that sets the connection timeout and requests timeout
* Remove the outdated interface associated with the Object Group * The problem of content-type cannot be specified when restoring multipart uploads
* The message in the OssException is changed to English
## v2.0.1
### Repair problem
* Increase the ListObjects/ListMultipartUploads special characters
* The object name is not complete * 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

@ -111,7 +111,7 @@ OssClient提供的接口返回返回数据分为两种
$bucketListInfo = $ossClient->listBuckets(); $bucketListInfo = $ossClient->listBuckets();
$bucketList = $bucketListInfo->getBucketList(); $bucketList = $bucketListInfo->getBucketList();
foreach($bucketList as $bucket) { foreach($bucketList as $bucket) {
print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n"); print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreateDate() . "\n");
} }
``` ```
上面代码中的$bucketListInfo的数据类型是 `OSS\Model\BucketListInfo` 上面代码中的$bucketListInfo的数据类型是 `OSS\Model\BucketListInfo`

View File

@ -1,150 +1,150 @@
# Alibaba Cloud OSS SDK for PHP # Alibaba Cloud OSS SDK for PHP
[![Latest Stable Version](https://poser.pugx.org/aliyuncs/oss-sdk-php/v/stable)](https://packagist.org/packages/aliyuncs/oss-sdk-php) [![Latest Stable Version](https://poser.pugx.org/aliyuncs/oss-sdk-php/v/stable)](https://packagist.org/packages/aliyuncs/oss-sdk-php)
[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk) [![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk)
[![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-php-sdk?branch=master) [![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-php-sdk?branch=master)
## [README of Chinese](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README-CN.md) ## [README of Chinese](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README-CN.md)
## Overview ## Overview
Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring a massive capacity, security, a low cost, and high reliability. You can upload and download data on any application anytime and anywhere by calling APIs, and perform simple management of data through the web console. The OSS can store any type of files and therefore applies to various websites, development enterprises and developers. Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring a massive capacity, security, a low cost, and high reliability. You can upload and download data on any application anytime and anywhere by calling APIs, and perform simple management of data through the web console. The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.
## Run environment ## Run environment
- PHP 5.3+. - PHP 5.3+.
- cURL extension. - cURL extension.
Tips: Tips:
- In Ubuntu, you can use the ***apt-get*** package manager to install the *PHP cURL extension*: `sudo apt-get install php5-curl`. - In Ubuntu, you can use the ***apt-get*** package manager to install the *PHP cURL extension*: `sudo apt-get install php5-curl`.
## Install OSS PHP SDK ## Install OSS PHP SDK
- If you use the ***composer*** to manage project dependencies, run the following command in your project's root directory: - If you use the ***composer*** to manage project dependencies, run the following command in your project's root directory:
composer require aliyuncs/oss-sdk-php composer require aliyuncs/oss-sdk-php
You can also declare the dependency on Alibaba Cloud OSS SDK for PHP in the `composer.json` file. You can also declare the dependency on Alibaba Cloud OSS SDK for PHP in the `composer.json` file.
"require": { "require": {
"aliyuncs/oss-sdk-php": "~2.0" "aliyuncs/oss-sdk-php": "~2.0"
} }
Then run `composer install` to install the dependency. After the Composer Dependency Manager is installed, import the dependency in your PHP code: Then run `composer install` to install the dependency. After the Composer Dependency Manager is installed, import the dependency in your PHP code:
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/vendor/autoload.php';
- You can also directly download the packaged [PHAR File][releases-page], and - You can also directly download the packaged [PHAR File][releases-page], and
introduce the file to your code: introduce the file to your code:
require_once '/path/to/oss-sdk-php.phar'; require_once '/path/to/oss-sdk-php.phar';
- Download the SDK source code, and introduce the `autoload.php` file under the SDK directory to your code: - Download the SDK source code, and introduce the `autoload.php` file under the SDK directory to your code:
require_once '/path/to/oss-sdk/autoload.php'; require_once '/path/to/oss-sdk/autoload.php';
## Quick use ## Quick use
### Common classes ### Common classes
| Class | Explanation | | Class | Explanation |
|:------------------|:------------------------------------| |:------------------|:------------------------------------|
|OSS\OSSClient | OSS client class. An OSSClient instance can be used to call the interface. | |OSS\OssClient | OSS client class. An OssClient instance can be used to call the interface. |
|OSS\Core\OSSException |OSS Exception class . You only need to pay attention to this exception when you use the OSSClient. | |OSS\Core\OssException |OSS Exception class . You only need to pay attention to this exception when you use the OssClient. |
### Initialize an OSSClient ### Initialize an OssClient
The SDK's operations for the OSS are performed through the OSSClient class. The code below creates an OSSClient object: The SDK's operations for the OSS are performed through the OssClient class. The code below creates an OssClient object:
```php ```php
<?php <?php
$accessKeyId = "<AccessKeyID that you obtain from OSS>"; $accessKeyId = "<AccessKeyID that you obtain from OSS>";
$accessKeySecret = "<AccessKeySecret that you obtain from OSS>"; $accessKeySecret = "<AccessKeySecret that you obtain from OSS>";
$endpoint = "<Domain that you select to access an OSS data center, such as "oss-cn-hangzhou.aliyuncs.com>"; $endpoint = "<Domain that you select to access an OSS data center, such as "oss-cn-hangzhou.aliyuncs.com>";
try { try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
} catch (OssException $e) { } catch (OssException $e) {
print $e->getMessage(); print $e->getMessage();
} }
``` ```
### Operations on objects ### Operations on objects
Objects are the most basic data units on the OSS. You can simply consider objects as files. The following code uploads an object: Objects are the most basic data units on the OSS. You can simply consider objects as files. The following code uploads an object:
```php ```php
<?php <?php
$bucket= "<Name of the bucket in use. Pay attention to naming conventions>"; $bucket= "<Name of the bucket in use. Pay attention to naming conventions>";
$object = "<Name of the object in use. Pay attention to naming conventions>"; $object = "<Name of the object in use. Pay attention to naming conventions>";
$content = "Hello, OSS!"; // Content of the uploaded file $content = "Hello, OSS!"; // Content of the uploaded file
try { try {
$ossClient->putObject($bucket, $object, $content); $ossClient->putObject($bucket, $object, $content);
} catch (OssException $e) { } catch (OssException $e) {
print $e->getMessage(); print $e->getMessage();
} }
``` ```
### Operations on buckets ### Operations on buckets
Buckets are the space that you use to manage the stored objects. It is an object management unit for users. Each object must belong to a bucket. You can create a bucket with the following code: Buckets are the space that you use to manage the stored objects. It is an object management unit for users. Each object must belong to a bucket. You can create a bucket with the following code:
```php ```php
<?php <?php
$bucket= "<Name of the bucket in use. Pay attention to naming conventions>"; $bucket= "<Name of the bucket in use. Pay attention to naming conventions>";
try { try {
$ossClient->createBucket($bucket); $ossClient->createBucket($bucket);
} catch (OssException $e) { } catch (OssException $e) {
print $e->getMessage(); print $e->getMessage();
} }
``` ```
### Handle returned results ### Handle returned results
The OSSClient provides the following two types of returned data from interfaces: The OssClient provides the following two types of returned data from interfaces:
- Put and Delete interfaces: The *PUT* and *DELETE* operations are deemed successful if *null* is returned by the interfaces without *OSSException*. - Put and Delete interfaces: The *PUT* and *DELETE* operations are deemed successful if *null* is returned by the interfaces without *OSSException*.
- Get and List interfaces: The *GET* and *LIST* operations are deemed successful if the desired data is returned by the interfaces without *OSSException*. For example, - Get and List interfaces: The *GET* and *LIST* operations are deemed successful if the desired data is returned by the interfaces without *OSSException*. For example,
```php ```php
<?php <?php
$bucketListInfo = $ossClient->listBuckets(); $bucketListInfo = $ossClient->listBuckets();
$bucketList = $bucketListInfo->getBucketList(); $bucketList = $bucketListInfo->getBucketList();
foreach($bucketList as $bucket) { foreach($bucketList as $bucket) {
print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n"); print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreateDate() . "\n");
} }
``` ```
In the above code, $bucketListInfo falls into the 'OSS\Model\BucketListInfo' data type. In the above code, $bucketListInfo falls into the 'OSS\Model\BucketListInfo' data type.
### Run a sample project ### Run a sample project
- Modify `samples/Config.php` to complete the configuration information. - Modify `samples/Config.php` to complete the configuration information.
- Run `cd samples/ && php RunAll.php`. - Run `cd samples/ && php RunAll.php`.
### Run a unit test ### Run a unit test
- Run `composer install` to download the dependent libraries. - Run `composer install` to download the dependent libraries.
- Set the environment variable. - Set the environment variable.
export OSS_ACCESS_KEY_ID=access-key-id export OSS_ACCESS_KEY_ID=access-key-id
export OSS_ACCESS_KEY_SECRET=access-key-secret export OSS_ACCESS_KEY_SECRET=access-key-secret
export OSS_ENDPOINT=endpoint export OSS_ENDPOINT=endpoint
export OSS_BUCKET=bucket-name export OSS_BUCKET=bucket-name
- Run `php vendor/bin/phpunit` - Run `php vendor/bin/phpunit`
## License ## License
- MIT - MIT
## Contact us ## Contact us
- [Alibaba Cloud OSS official website](http://oss.aliyun.com). - [Alibaba Cloud OSS official website](http://oss.aliyun.com).
- [Alibaba Cloud OSS official forum](http://bbs.aliyun.com). - [Alibaba Cloud OSS official forum](http://bbs.aliyun.com).
- [Alibaba Cloud OSS official documentation center](http://www.aliyun.com/product/oss#Docs). - [Alibaba Cloud OSS official documentation center](http://www.aliyun.com/product/oss#Docs).
- Alibaba Cloud official technical support: [Submit a ticket](https://workorder.console.aliyun.com/#/ticket/createIndex). - Alibaba Cloud official technical support: [Submit a ticket](https://workorder.console.aliyun.com/#/ticket/createIndex).
[releases-page]: https://github.com/aliyun/aliyun-oss-php-sdk/releases [releases-page]: https://github.com/aliyun/aliyun-oss-php-sdk/releases
[phar-composer]: https://github.com/clue/phar-composer [phar-composer]: https://github.com/clue/phar-composer

File diff suppressed because it is too large Load Diff

View File

@ -713,6 +713,8 @@ class RequestCore
$temp_headers[] = $k . ': ' . $v; $temp_headers[] = $k . ': ' . $v;
} }
// fix "Expect: 100-continue"
$temp_headers[] = 'Expect:';
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $temp_headers); curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $temp_headers);
} }

View File

@ -11,20 +11,20 @@ namespace OSS\Model;
*/ */
class BucketInfo class BucketInfo
{ {
/** /**
* BucketInfo constructor. * BucketInfo constructor.
* *
* @param string $location * @param string $location
* @param string $name * @param string $name
* @param string $createDate * @param string $createDate
*/ */
public function __construct($location, $name, $createDate) public function __construct($location = '', $name = '', $createDate = '')
{ {
$this->location = $location; $this->location = $location;
$this->name = $name;
$this->createDate = $createDate; $this->createDate = $createDate;
$this->name = $name;
} }
/** /**
* Get bucket location * Get bucket location
* *
@ -55,6 +55,82 @@ class BucketInfo
return $this->createDate; return $this->createDate;
} }
/**
* Get bucket storage class.
*
* @return string
*/
public function getStorageClass()
{
return $this->storageClass;
}
/**
* Get bucket extranet endpoint.
*
* @return string
*/
public function getExtranetEndpoint()
{
return $this->extranetEndpoint;
}
/**
* Get bucket intranet endpoint.
*
* @return string
*/
public function getIntranetEndpoint()
{
return $this->intranetEndpoint;
}
/**
* Get bucket intranet endpoint.
*
* @return string
*/
public function getRegion()
{
return $this->region;
}
/**
* Parse bucket information from node.
*
* @param xml $xml
* @throws OssException
* @return null
*/
public function parseFromXmlNode($xml)
{
if (isset($xml->Location)) {
$this->location = strval($xml->Location);
}
if (isset($xml->Name)) {
$this->name = strval($xml->Name);
}
if (isset($xml->CreationDate)) {
$this->createDate = strval($xml->CreationDate);
}
if (isset($xml->StorageClass)) {
$this->storageClass = strval($xml->StorageClass);
}
if (isset($xml->ExtranetEndpoint)) {
$this->extranetEndpoint = strval($xml->ExtranetEndpoint);
}
if (isset($xml->IntranetEndpoint)) {
$this->intranetEndpoint = strval($xml->IntranetEndpoint);
}
if (isset($xml->IntranetEndpoint)) {
$this->intranetEndpoint = strval($xml->IntranetEndpoint);
}
if (isset($xml->Region)) {
$this->region = strval($xml->Region);
}
}
/** /**
* bucket region * bucket region
* *
@ -75,4 +151,31 @@ class BucketInfo
*/ */
private $createDate; private $createDate;
/**
* bucket storage class
*
* @var string
*/
private $storageClass;
/**
* bucket extranet endpoint
*
* @var string
*/
private $extranetEndpoint;
/**
* bucket intranet endpoint
*
* @var string
*/
private $intranetEndpoint;
/**
* bucket region
*
* @var string
*/
private $region;
} }

View File

@ -0,0 +1,85 @@
<?php
namespace OSS\Model;
/**
* Bucket stat class.
*
* Class BucketStat
* @package OSS\Model
*/
class BucketStat
{
/**
* Get storage
*
* @return int
*/
public function getStorage()
{
return $this->storage;
}
/**
* Get object count
*
* @return int
*/
public function getObjectCount()
{
return $this->objectCount;
}
/**
* Get multipart upload count.
*
* @return int
*/
public function getMultipartUploadCount()
{
return $this->multipartUploadCount;
}
/**
* Parse stat from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (isset($xml->Storage) ) {
$this->storage = intval($xml->Storage);
}
if (isset($xml->ObjectCount) ) {
$this->objectCount = intval($xml->ObjectCount);
}
if (isset($xml->MultipartUploadCount) ) {
$this->multipartUploadCount = intval($xml->MultipartUploadCount);
}
}
/**
* current storage
*
* @var int
*/
private $storage;
/**
* object count
*
* @var int
*/
private $objectCount;
/**
* multipart upload count
*
* @var int
*/
private $multipartUploadCount;
}

View File

@ -0,0 +1,65 @@
<?php
namespace OSS\Model;
/**
*
* Class DeleteMarkerInfo
*
* @package OSS\Model
*/
class DeleteMarkerInfo
{
/**
* DeleteMarkerInfo constructor.
*
* @param string $key
* @param string $versionId
* @param string $lastModified
* @param string $isLatest
*/
public function __construct($key, $versionId, $lastModified, $isLatest)
{
$this->key = $key;
$this->versionId = $versionId;
$this->lastModified = $lastModified;
$this->isLatest = $isLatest;
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @return string
*/
public function getVersionId()
{
return $this->versionId;
}
/**
* @return string
*/
public function getLastModified()
{
return $this->lastModified;
}
/**
* @return string
*/
public function getIsLatest()
{
return $this->isLatest;
}
private $key = "";
private $versionId = "";
private $lastModified = "";
private $isLatest = "";
}

View File

@ -0,0 +1,41 @@
<?php
namespace OSS\Model;
/**
* Class DeleteObjectInfo
* @package OSS\Model
*/
class DeleteObjectInfo
{
/**
* DeleteObjectInfo constructor.
*
* @param string $key
* @param string $versionId
*/
public function __construct($key, $versionId = '')
{
$this->key = $key;
$this->versionId = $versionId;
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @return string
*/
public function getVersionId()
{
return $this->versionId;
}
private $key = "";
private $versionId = "";
}

View File

@ -0,0 +1,63 @@
<?php
namespace OSS\Model;
/**
* Class DeletedObjectInfo
* @package OSS\Model
*/
class DeletedObjectInfo
{
/**
* DeletedObjectInfo constructor.
*
* @param string $key
* @param string $versionId
* @param string $deleteMarker
* @param string $deleteMarkerVersionId
*/
public function __construct($key, $versionId, $deleteMarker, $deleteMarkerVersionId)
{
$this->key = $key;
$this->versionId = $versionId;
$this->deleteMarker = $deleteMarker;
$this->deleteMarkerVersionId = $deleteMarkerVersionId;
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @return string
*/
public function getVersionId()
{
return $this->versionId;
}
/**
* @return string
*/
public function getDeleteMarker()
{
return $this->deleteMarker;
}
/**
* @return string
*/
public function getDeleteMarkerVersionId()
{
return $this->deleteMarkerVersionId;
}
private $key = "";
private $versionId = "";
private $deleteMarker = "";
private $deleteMarkerVersionId = "";
}

View File

@ -0,0 +1,64 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class ExtendWormConfig
* @package OSS\Model
*
*/
class ExtendWormConfig implements XmlConfig
{
/**
* ExtendWormConfig constructor.
* @param null $day
*/
public function __construct($day = null)
{
$this->day = $day;
}
/**
* Parse ExtendWormConfig from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
throw new OssException("Not implemented.");
}
/**
* Serialize the object into xml string.
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><ExtendWormConfiguration></ExtendWormConfiguration>');
if (isset($this->day)) {
$xml->addChild('RetentionPeriodInDays', $this->day);
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
/**
* @return int
*/
public function getDay()
{
return $this->day;
}
private $day = 0;
}

View File

@ -1,6 +1,9 @@
<?php <?php
namespace OSS\Model; namespace OSS\Model;
use OSS\Core\OssException;
/** /**
* Class GetLiveChannelHistory * Class GetLiveChannelHistory
* @package OSS\Model * @package OSS\Model

View File

@ -0,0 +1,64 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class InitiateWormConfig
* @package OSS\Model
*
*/
class InitiateWormConfig implements XmlConfig
{
/**
* InitiateWormConfig constructor.
* @param null $day
*/
public function __construct($day = null)
{
$this->day = $day;
}
/**
* Parse InitiateWormConfig from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
throw new OssException("Not implemented.");
}
/**
* Serialize the object into xml string.
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><InitiateWormConfiguration></InitiateWormConfiguration>');
if (isset($this->day)) {
$xml->addChild('RetentionPeriodInDays', $this->day);
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
/**
* @return int
*/
public function getDay()
{
return $this->day;
}
private $day = 0;
}

View File

@ -0,0 +1,114 @@
<?php
namespace OSS\Model;
/**
*
* Class ObjectVersionInfo
*
* The element type of ObjectVersionListInfo, which is the return value type of listObjectVersions
*
* The return value of listObjectVersions includes three arrays
* One is the returned ObjectVersionListInfo, 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
*/
class ObjectVersionInfo
{
/**
* ObjectVersionInfo constructor.
*
* @param string $key
* @param string $lastModified
* @param string $eTag
* @param string $type
* @param int $size
* @param string $storageClass
* @param string $isLatest
*/
public function __construct($key, $versionId, $lastModified, $eTag, $type, $size, $storageClass, $isLatest)
{
$this->key = $key;
$this->versionId = $versionId;
$this->lastModified = $lastModified;
$this->eTag = $eTag;
$this->type = $type;
$this->size = $size;
$this->storageClass = $storageClass;
$this->isLatest = $isLatest;
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @return string
*/
public function getVersionId()
{
return $this->versionId;
}
/**
* @return string
*/
public function getLastModified()
{
return $this->lastModified;
}
/**
* @return string
*/
public function getETag()
{
return $this->eTag;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return int
*/
public function getSize()
{
return $this->size;
}
/**
* @return string
*/
public function getStorageClass()
{
return $this->storageClass;
}
/**
* @return string
*/
public function getIsLatest()
{
return $this->isLatest;
}
private $key = "";
private $versionId = "";
private $lastModified = "";
private $eTag = "";
private $type = "";
private $size = 0;
private $storageClass = "";
private $isLatest = "";
}

View File

@ -0,0 +1,162 @@
<?php
namespace OSS\Model;
/**
* Class ObjectVersionListInfo
*
* The class of return value of ListObjectVersions
*
* @package OSS\Model
*/
class ObjectVersionListInfo
{
/**
* ObjectVersionListInfo constructor.
*
* @param string $bucketName
* @param string $prefix
* @param string $keyMarker
* @param string $nextKeyMarker
* @param string $versionIdMarker
* @param string $nextVersionIdMarker
* @param string $maxKeys
* @param string $delimiter
* @param null $isTruncated
* @param array $objectversionList
* @param array $deleteMarkerList
* @param array $prefixList
*/
public function __construct($bucketName, $prefix, $keyMarker, $nextKeyMarker, $versionIdMarker, $nextVersionIdMarker
, $maxKeys, $delimiter, $isTruncated
, array $objectversionList, array $deleteMarkerList, array $prefixList)
{
$this->bucketName = $bucketName;
$this->prefix = $prefix;
$this->keyMarker = $keyMarker;
$this->nextKeyMarker = $nextKeyMarker;
$this->versionIdMarker = $versionIdMarker;
$this->nextVersionIdMarker = $nextVersionIdMarker;
$this->maxKeys = $maxKeys;
$this->delimiter = $delimiter;
$this->isTruncated = $isTruncated;
$this->objectVersionList = $objectversionList;
$this->deleteMarkerList = $deleteMarkerList;
$this->prefixList = $prefixList;
}
/**
* @return string
*/
public function getBucketName()
{
return $this->bucketName;
}
/**
* @return string
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* @return string
*/
public function getKeyMarker()
{
return $this->keyMarker;
}
/**
* @return string
*/
public function getNextKeyMarker()
{
return $this->nextKeyMarker;
}
/**
* @return string
*/
public function getVersionIdMarker()
{
return $this->versionIdMarker;
}
/**
* @return string
*/
public function getNextVersionIdMarker()
{
return $this->nextVersionIdMarker;
}
/**
* @return int
*/
public function getMaxKeys()
{
return $this->maxKeys;
}
/**
* @return string
*/
public function getDelimiter()
{
return $this->delimiter;
}
/**
* @return mixed
*/
public function getIsTruncated()
{
return $this->isTruncated;
}
/**
* Get the ObjectVersionInfo list.
*
* @return ObjectVersionInfo[]
*/
public function getObjectVersionList()
{
return $this->objectVersionList;
}
/**
* Get the DeleteMarkerInfo list.
*
* @return DeleteMarkerInfo[]
*/
public function getDeleteMarkerList()
{
return $this->deleteMarkerList;
}
/**
* Get the PrefixInfo list
*
* @return PrefixInfo[]
*/
public function getPrefixList()
{
return $this->prefixList;
}
private $bucketName = "";
private $prefix = "";
private $keyMarker = "";
private $nextKeyMarker = "";
private $versionIdmarker = "";
private $nextVersionIdMarker = "";
private $maxKeys = 0;
private $delimiter = "";
private $isTruncated = null;
private $objectVersionList = array();
private $deleteMarkerList = array();
private $prefixList = array();
}

View File

@ -0,0 +1,68 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class RequestPaymentConfig
* @package OSS\Model
*
* @link https://help.aliyun.com/document_detail/117914.htm
*/
class RequestPaymentConfig implements XmlConfig
{
/**
* RequestPaymentConfig constructor.
* @param null $payer
*/
public function __construct($payer = null)
{
$this->payer = $payer;
}
/**
* Parse ServerSideEncryptionConfig from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (isset($xml->Payer)) {
$this->payer = strval($xml->Payer);
}
}
/**
* Serialize the object into xml string.
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><RequestPaymentConfiguration></RequestPaymentConfiguration>');
if (isset($this->payer)) {
$xml->addChild('Payer', $this->payer);
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
/**
* @return string
*/
public function getPayer()
{
return $this->payer;
}
private $payer = "";
}

View File

@ -0,0 +1,77 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class RestoreConfig
* @package OSS\Model
*
*/
class RestoreConfig implements XmlConfig
{
/**
* RestoreConfig constructor.
* @param int $day
* @param null $tier
*/
public function __construct($day, $tier = null)
{
$this->day = $day;
$this->tier = $tier;
}
/**
* Parse RestoreConfig from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
throw new OssException("Not implemented.");
}
/**
* Serialize the object into xml string.
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><RestoreRequest></RestoreRequest>');
$xml->addChild('Days', strval($this->day));
if (isset($this->tier)) {
$xml_param = $xml->addChild('JobParameters');
$xml_param->addChild('Tier', $this->tier);
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
/**
* @return int
*/
public function getDay()
{
return $this->day;
}
/**
* @return string
*/
public function getTier()
{
return $this->tier;
}
private $day = 1;
private $tier = 'Standard';
}

View File

@ -0,0 +1,91 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class ServerSideEncryptionConfig
* @package OSS\Model
*
* @link https://help.aliyun.com/document_detail/117914.htm
*/
class ServerSideEncryptionConfig implements XmlConfig
{
/**
* ServerSideEncryptionConfig constructor.
* @param null $sseAlgorithm
* @param null $kmsMasterKeyID
*/
public function __construct($sseAlgorithm = null, $kmsMasterKeyID = null)
{
$this->sseAlgorithm = $sseAlgorithm;
$this->kmsMasterKeyID = $kmsMasterKeyID;
}
/**
* Parse ServerSideEncryptionConfig from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (!isset($xml->ApplyServerSideEncryptionByDefault)) return;
foreach ($xml->ApplyServerSideEncryptionByDefault as $default) {
foreach ($default as $key => $value) {
if ($key === 'SSEAlgorithm') {
$this->sseAlgorithm = strval($value);
} elseif ($key === 'KMSMasterKeyID') {
$this->kmsMasterKeyID = strval($value);
}
}
break;
}
}
/**
* Serialize the object into xml string.
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><ServerSideEncryptionRule></ServerSideEncryptionRule>');
$default = $xml->addChild('ApplyServerSideEncryptionByDefault');
if (isset($this->sseAlgorithm)) {
$default->addChild('SSEAlgorithm', $this->sseAlgorithm);
}
if (isset($this->kmsMasterKeyID)) {
$default->addChild('KMSMasterKeyID', $this->kmsMasterKeyID);
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
/**
* @return string
*/
public function getSSEAlgorithm()
{
return $this->sseAlgorithm;
}
/**
* @return string
*/
public function getKMSMasterKeyID()
{
return $this->kmsMasterKeyID;
}
private $sseAlgorithm = "";
private $kmsMasterKeyID = "";
}

View File

@ -2,6 +2,8 @@
namespace OSS\Model; namespace OSS\Model;
use OSS\Core\OssException;
/** /**
* Class StorageCapacityConfig * Class StorageCapacityConfig
* *

View File

@ -0,0 +1,41 @@
<?php
namespace OSS\Model;
/**
* Class Tag
* @package OSS\Model
*/
class Tag
{
/**
* Tag constructor.
*
* @param string $key
* @param string $value
*/
public function __construct($key, $value)
{
$this->key = $key;
$this->value = $value;
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @return string
*/
public function getValue()
{
return $this->value;
}
private $key = "";
private $value = "";
}

View File

@ -0,0 +1,89 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class TaggingConfig
* @package OSS\Model
*
*/
class TaggingConfig implements XmlConfig
{
/**
* TaggingConfig constructor.
*/
public function __construct()
{
$this->tags = array();
}
/**
* Get Tag list
*
* @return Tag[]
*/
public function getTags()
{
return $this->tags;
}
/**
* Add a new Tag
*
* @param Tag $tag
* @throws OssException
*/
public function addTag($tag)
{
$this->tags[] = $tag;
}
/**
* Parse TaggingConfig from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (!isset($xml->TagSet) || !isset($xml->TagSet->Tag)) return;
foreach ($xml->TagSet->Tag as $tag) {
$this->addTag(new Tag($tag->Key, $tag->Value));
}
}
/**
* Serialize the object into xml string.
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><Tagging></Tagging>');
$xmlTagSet = $xml->addChild('TagSet');
foreach ($this->tags as $tag) {
$xmlTag = $xmlTagSet->addChild('Tag');
$xmlTag->addChild('Key', strval($tag->getKey()));
$xmlTag->addChild('Value', strval($tag->getValue()));
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
/**
* Tag list
*
* @var Tag[]
*/
private $tags = array();
}

View File

@ -0,0 +1,67 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class VersioningConfig
* @package OSS\Model
*
*/
class VersioningConfig implements XmlConfig
{
/**
* VersioningConfig constructor.
* @param null $status
*/
public function __construct($status = null)
{
$this->status = $status;
}
/**
* Parse VersioningConfig from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (isset($xml->Status)) {
$this->status = strval($xml->Status);
}
}
/**
* Serialize the object into xml string.
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><VersioningConfiguration></VersioningConfiguration>');
if (isset($this->status)) {
$xml->addChild('Status', $this->status);
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
/**
* @return string
*/
public function getStatus()
{
return $this->status;
}
private $status = "";
}

View File

@ -0,0 +1,90 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class WormConfig
* @package OSS\Model
*
*/
class WormConfig implements XmlConfig
{
/**
* Parse WormConfig from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (isset($xml->WormId)) {
$this->wormId = strval($xml->WormId);
}
if (isset($xml->State)) {
$this->state = strval($xml->State);
}
if (isset($xml->RetentionPeriodInDays)) {
$this->day = intval($xml->RetentionPeriodInDays);
}
if (isset($xml->CreationDate)) {
$this->creationDate = strval($xml->CreationDate);
}
}
/**
* Serialize the object into xml string.
*
* @return string
*/
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
public function __toString()
{
return $this->serializeToXml();
}
/**
* @return string
*/
public function getWormId()
{
return $this->wormId;
}
/**
* @return string
*/
public function getState()
{
return $this->state;
}
/**
* @return int
*/
public function getDay()
{
return $this->day;
}
/**
* @return string
*/
public function getCreationDate()
{
return $this->creationDate;
}
private $wormId = '';
private $state = '';
private $creationDate = '';
private $day = 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,6 @@ class CopyObjectResult extends Result
$result[] = $xml->ETag; $result[] = $xml->ETag;
} }
return $result; return array_merge($result, $this->rawResponse->header);
} }
} }

View File

@ -0,0 +1,39 @@
<?php
namespace OSS\Result;
use OSS\Core\OssUtil;
use OSS\Model\DeletedObjectInfo;
/**
* Class DeleteObjectVersionsResult
* @package OSS\Result
*/
class DeleteObjectVersionsResult extends Result
{
/**
* @return DeletedObjectInfo[]
*/
protected function parseDataFromResponse()
{
$xml = simplexml_load_string($this->rawResponse->body);
$encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
return $this->parseDeletedList($xml, $encodingType);
}
private function parseDeletedList($xml, $encodingType)
{
$retList = array();
if (isset($xml->Deleted)) {
foreach ($xml->Deleted as $content) {
$key = isset($content->Key) ? strval($content->Key) : "";
$key = OssUtil::decodeKey($key, $encodingType);
$versionId = isset($content->VersionId) ? strval($content->VersionId) : "";
$deleteMarker = isset($content->DeleteMarker) ? strval($content->DeleteMarker) : "";
$deleteMarkerVersionId = isset($content->DeleteMarkerVersionId) ? strval($content->DeleteMarkerVersionId) : "";
$retList[] = new DeletedObjectInfo($key, $versionId, $deleteMarker, $deleteMarkerVersionId);
}
}
return $retList;
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace OSS\Result;
use OSS\Model\ServerSideEncryptionConfig;
/**
* Class GetBucketEncryptionResult
* @package OSS\Result
*/
class GetBucketEncryptionResult extends Result
{
/**
* Parse the ServerSideEncryptionConfig object from the response
*
* @return ServerSideEncryptionConfig
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$config = new ServerSideEncryptionConfig();
$config->parseFromXml($content);
return $config;
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace OSS\Result;
use OSS\Core\OssException;
use OSS\Model\BucketInfo;
/**
* Class GetBucketResult interface returns the result class, encapsulated
* The returned xml data is parsed
*
* @package OSS\Result
*/
class GetBucketInfoResult extends Result
{
/**
* Parse data from response
*
* @return string
* @throws OssException
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
if (empty($content)) {
throw new OssException("body is null");
}
$xml = simplexml_load_string($content);
if (isset($xml->Bucket)) {
$info = new BucketInfo();
$info->parseFromXmlNode($xml->Bucket);
return $info;
} else {
throw new OssException("xml format exception");
}
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace OSS\Result;
use OSS\Model\RequestPaymentConfig;
/**
* Class GetBucketRequestPaymentResult
* @package OSS\Result
*/
class GetBucketRequestPaymentResult extends Result
{
/**
* Parse the RequestPaymentConfig object from the response
*
* @return RequestPaymentConfig
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$config = new RequestPaymentConfig();
$config->parseFromXml($content);
return $config->getPayer();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace OSS\Result;
use OSS\Model\BucketStat;
/**
* Class GetRefererResult
* @package OSS\Result
*/
class GetBucketStatResult extends Result
{
/**
* Parse bucket stat data
*
* @return BucketStat
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$stat = new BucketStat();
$stat->parseFromXml($content);
return $stat;
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace OSS\Result;
use OSS\Model\TaggingConfig;
/**
* Class GetBucketTagsResult
* @package OSS\Result
*/
class GetBucketTagsResult extends Result
{
/**
* Parse the TaggingConfig object from the response
*
* @return TaggingConfig
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$config = new TaggingConfig();
$config->parseFromXml($content);
return $config;
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace OSS\Result;
use OSS\Model\VersioningConfig;
/**
* Class GetBucketVersioningResult
* @package OSS\Result
*/
class GetBucketVersioningResult extends Result
{
/**
* Parse the VersioningConfig object from the response
*
* @return VersioningConfig
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$config = new VersioningConfig();
$config->parseFromXml($content);
return $config->getStatus();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace OSS\Result;
use OSS\Model\WormConfig;
/**
* Class GetBucketWormResult
* @package OSS\Result
*/
class GetBucketWormResult extends Result
{
/**
* Parse bucket stat data
*
* @return WormConfig
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$config = new WormConfig();
$config->parseFromXml($content);
return $config;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace OSS\Result;
use OSS\Core\OssException;
/**
* Class InitiateBucketWormResult
* @package OSS\Result
*/
class InitiateBucketWormResult extends Result
{
/**
* Get the value of worm-id from response headers
*
* @return int
* @throws OssException
*/
protected function parseDataFromResponse()
{
$header = $this->rawResponse->header;
if (isset($header["x-oss-worm-id"])) {
return strval($header["x-oss-worm-id"]);
}
throw new OssException("cannot get worm-id");
}
}

View File

@ -22,9 +22,8 @@ class ListBucketsResult extends Result
$xml = new \SimpleXMLElement($content); $xml = new \SimpleXMLElement($content);
if (isset($xml->Buckets) && isset($xml->Buckets->Bucket)) { if (isset($xml->Buckets) && isset($xml->Buckets->Bucket)) {
foreach ($xml->Buckets->Bucket as $bucket) { foreach ($xml->Buckets->Bucket as $bucket) {
$bucketInfo = new BucketInfo(strval($bucket->Location), $bucketInfo = new BucketInfo();
strval($bucket->Name), $bucketInfo->parseFromXmlNode($bucket);
strval($bucket->CreationDate));
$bucketList[] = $bucketInfo; $bucketList[] = $bucketInfo;
} }
} }

View File

@ -0,0 +1,96 @@
<?php
namespace OSS\Result;
use OSS\Core\OssUtil;
use OSS\Model\ObjectVersionInfo;
use OSS\Model\ObjectVersionListInfo;
use OSS\Model\DeleteMarkerInfo;
use OSS\Model\PrefixInfo;
/**
* Class ListObjectVersionsResult
* @package OSS\Result
*/
class ListObjectVersionsResult extends Result
{
/**
* Parse the xml data returned by the ListObjectVersions interface
*
* return ObjectVersionListInfo
*/
protected function parseDataFromResponse()
{
$xml = simplexml_load_string($this->rawResponse->body);
$encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
$objectVersionList = $this->parseObjecVersionList($xml, $encodingType);
$deleteMarkerList = $this->parseDeleteMarkerList($xml, $encodingType);
$prefixList = $this->parsePrefixList($xml, $encodingType);
$bucketName = isset($xml->Name) ? strval($xml->Name) : "";
$prefix = isset($xml->Prefix) ? strval($xml->Prefix) : "";
$prefix = OssUtil::decodeKey($prefix, $encodingType);
$keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : "";
$keyMarker = OssUtil::decodeKey($keyMarker, $encodingType);
$nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : "";
$nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType);
$versionIdMarker = isset($xml->VersionIdMarker) ? strval($xml->VersionIdMarker) : "";
$nextVersionIdMarker = isset($xml->NextVersionIdMarker) ? strval($xml->NextVersionIdMarker) : "";
$maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0;
$delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : "";
$delimiter = OssUtil::decodeKey($delimiter, $encodingType);
$isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : "";
return new ObjectVersionListInfo($bucketName, $prefix, $keyMarker, $nextKeyMarker,
$versionIdMarker, $nextVersionIdMarker,$maxKeys, $delimiter, $isTruncated,
$objectVersionList, $deleteMarkerList, $prefixList);
}
private function parseObjecVersionList($xml, $encodingType)
{
$retList = array();
if (isset($xml->Version)) {
foreach ($xml->Version as $content) {
$key = isset($content->Key) ? strval($content->Key) : "";
$key = OssUtil::decodeKey($key, $encodingType);
$versionId = isset($content->VersionId) ? strval($content->VersionId) : "";
$lastModified = isset($content->LastModified) ? strval($content->LastModified) : "";
$eTag = isset($content->ETag) ? strval($content->ETag) : "";
$type = isset($content->Type) ? strval($content->Type) : "";
$size = isset($content->Size) ? intval($content->Size) : 0;
$storageClass = isset($content->StorageClass) ? strval($content->StorageClass) : "";
$isLatest = isset($content->IsLatest) ? strval($content->IsLatest) : "";
$retList[] = new ObjectVersionInfo($key, $versionId, $lastModified, $eTag, $type, $size, $storageClass, $isLatest);
}
}
return $retList;
}
private function parseDeleteMarkerList($xml, $encodingType)
{
$retList = array();
if (isset($xml->DeleteMarker)) {
foreach ($xml->DeleteMarker as $content) {
$key = isset($content->Key) ? strval($content->Key) : "";
$key = OssUtil::decodeKey($key, $encodingType);
$versionId = isset($content->VersionId) ? strval($content->VersionId) : "";
$lastModified = isset($content->LastModified) ? strval($content->LastModified) : "";
$isLatest = isset($content->IsLatest) ? strval($content->IsLatest) : "";
$retList[] = new DeleteMarkerInfo($key, $versionId, $lastModified, $isLatest);
}
}
return $retList;
}
private function parsePrefixList($xml, $encodingType)
{
$retList = array();
if (isset($xml->CommonPrefixes)) {
foreach ($xml->CommonPrefixes as $commonPrefix) {
$prefix = isset($commonPrefix->Prefix) ? strval($commonPrefix->Prefix) : "";
$prefix = OssUtil::decodeKey($prefix, $encodingType);
$retList[] = new PrefixInfo($prefix);
}
}
return $retList;
}
}

View File

@ -195,6 +195,39 @@ class BucketLiveChannelTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('playlist.m3u8', $query['playlistName']); $this->assertEquals('playlist.m3u8', $query['playlistName']);
} }
public function testGetgenPreSignedRtmpUrlVsSignedRtmpUrl()
{
$channelName = '90475';
$bucket = 'douyu';
$url1 = '245';
$url2 = '123';
$expiration = 0;
do {
$begin = time();
$expiration = time() + 900;
$url1 = $this->client->generatePresignedRtmpUrl($bucket, $channelName, $expiration, array(
'params' => array(
'playlistName' => 'playlist.m3u8'
)
));
$url2 = $this->client->signRtmpUrl($bucket, $channelName, 900, array(
'params' => array(
'playlistName' => 'playlist.m3u8'
)
));
$end = time();
if ($begin == $end)
break;
usleep(500000);
} while (true);
$this->assertEquals($url1, $url1);
$this->assertTrue(strpos($url1, 'Expires='.$expiration) !== false);
}
public function testLiveChannelInfo() public function testLiveChannelInfo()
{ {
$channelName = 'live-to-put-status'; $channelName = 'live-to-put-status';

View File

@ -4,7 +4,7 @@ namespace OSS\Tests;
require_once __DIR__ . '/Common.php'; require_once __DIR__ . '/Common.php';
class ContentTypeTest extends \PHPUnit_Framework_TestCase class ContentTypeTest extends TestOssClientBase
{ {
private function runCmd($cmd) private function runCmd($cmd)
{ {
@ -17,15 +17,15 @@ class ContentTypeTest extends \PHPUnit_Framework_TestCase
private function getContentType($bucket, $object) private function getContentType($bucket, $object)
{ {
$client = Common::getOssClient(); $client = $this->ossClient;
$headers = $client->getObjectMeta($bucket, $object); $headers = $client->getObjectMeta($bucket, $object);
return $headers['content-type']; return $headers['content-type'];
} }
public function testByFileName() public function testByFileName()
{ {
$client = Common::getOssClient(); $client = $this->ossClient;
$bucket = Common::getBucketName(); $bucket = $this->bucket;
$file = '/tmp/x.html'; $file = '/tmp/x.html';
$object = 'test/x'; $object = 'test/x';
@ -48,8 +48,8 @@ class ContentTypeTest extends \PHPUnit_Framework_TestCase
public function testByObjectKey() public function testByObjectKey()
{ {
$client = Common::getOssClient(); $client = $this->ossClient;
$bucket = Common::getBucketName(); $bucket = $this->bucket;
$object = "test/x.txt"; $object = "test/x.txt";
$client->putObject($bucket, $object, "hello world"); $client->putObject($bucket, $object, "hello world");
@ -96,8 +96,8 @@ class ContentTypeTest extends \PHPUnit_Framework_TestCase
public function testByUser() public function testByUser()
{ {
$client = Common::getOssClient(); $client = $this->ossClient;
$bucket = Common::getBucketName(); $bucket = $this->bucket;
$object = "test/x.txt"; $object = "test/x.txt";
$client->putObject($bucket, $object, "hello world", array( $client->putObject($bucket, $object, "hello world", array(

View File

@ -0,0 +1,187 @@
<?php
namespace OSS\Tests;
use OSS\Result\DeleteObjectVersionsResult;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
class DeleteObjectVersionsResultTest extends \PHPUnit_Framework_TestCase
{
private $validXml = <<<BBBB
<?xml version="1.0" ?>
<DeleteResult>
<Deleted>
<Key>demo.jpg</Key>
<VersionId>CAEQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk****</VersionId>
<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>111111</DeleteMarkerVersionId>
</Deleted>
</DeleteResult>
BBBB;
private $validXml1 = <<<BBBB
<?xml version="1.0" ?>
<DeleteResult>
<Deleted>
<Key>multipart.data</Key>
<VersionId>CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4****</VersionId>
</Deleted>
</DeleteResult>
BBBB;
private $validXml2 = <<<BBBB
<?xml version="1.0" ?>
<DeleteResult>
<Deleted>
<Key>multipart.data</Key>
<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>CAEQMhiBgIDXiaaB0BYiIGQzYmRkZGUxMTM1ZDRjOTZhNjk4YjRjMTAyZjhl****</DeleteMarkerVersionId>
</Deleted>
<Deleted>
<Key>test.jpg</Key>
<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy****</DeleteMarkerVersionId>
</Deleted>
</DeleteResult>
BBBB;
private $validXml3 = <<<BBBB
<?xml version="1.0" ?>
<DeleteResult>
<Deleted>
<Key>multipart.data</Key>
</Deleted>
<Deleted>
<Key>test.jpg</Key>
</Deleted>
<Deleted>
<Key>demo.jpg</Key>
</Deleted>
</DeleteResult>
BBBB;
private $validXml4 = <<<BBBB
<?xml version="1.0" ?>
<DeleteResult>
<EncodingType>url</EncodingType>
<Deleted>
<Key>multipart%2F.data</Key>
</Deleted>
<Deleted>
<Key>test%2F.jpg</Key>
</Deleted>
<Deleted>
<Key>demo%2F.jpg</Key>
</Deleted>
</DeleteResult>
BBBB;
private $invalidXml = <<<BBBB
<?xml version="1.0" ?>
<DeleteResult>
</DeleteResult>
BBBB;
public function testParseValidXml()
{
$response = new ResponseCore(array(), $this->validXml, 200);
$result = new DeleteObjectVersionsResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$list = $result->getData();
$this->assertEquals(1, count($list));
$this->assertEquals('demo.jpg', $list[0]->getKey());
$this->assertEquals('CAEQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk****', $list[0]->getVersionId());
$this->assertEquals('true', $list[0]->getDeleteMarker());
$this->assertEquals('111111', $list[0]->getDeleteMarkerVersionId());
$response = new ResponseCore(array(), $this->validXml1, 200);
$result = new DeleteObjectVersionsResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$list = $result->getData();
$this->assertEquals(1, count($list));
$this->assertEquals('multipart.data', $list[0]->getKey());
$this->assertEquals('CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4****', $list[0]->getVersionId());
$this->assertEquals('', $list[0]->getDeleteMarker());
$this->assertEquals('', $list[0]->getDeleteMarkerVersionId());
$response = new ResponseCore(array(), $this->validXml2, 200);
$result = new DeleteObjectVersionsResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$list = $result->getData();
$this->assertEquals(2, count($list));
$this->assertEquals('multipart.data', $list[0]->getKey());
$this->assertEquals('', $list[0]->getVersionId());
$this->assertEquals('true', $list[0]->getDeleteMarker());
$this->assertEquals('CAEQMhiBgIDXiaaB0BYiIGQzYmRkZGUxMTM1ZDRjOTZhNjk4YjRjMTAyZjhl****', $list[0]->getDeleteMarkerVersionId());
$this->assertEquals('test.jpg', $list[1]->getKey());
$this->assertEquals('', $list[1]->getVersionId());
$this->assertEquals('true', $list[1]->getDeleteMarker());
$this->assertEquals('CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy****', $list[1]->getDeleteMarkerVersionId());
$response = new ResponseCore(array(), $this->validXml3, 200);
$result = new DeleteObjectVersionsResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$list = $result->getData();
$this->assertEquals(3, count($list));
$this->assertEquals('multipart.data', $list[0]->getKey());
$this->assertEquals('', $list[0]->getVersionId());
$this->assertEquals('', $list[0]->getDeleteMarker());
$this->assertEquals('', $list[0]->getDeleteMarkerVersionId());
$this->assertEquals('test.jpg', $list[1]->getKey());
$this->assertEquals('', $list[1]->getVersionId());
$this->assertEquals('', $list[1]->getDeleteMarker());
$this->assertEquals('', $list[1]->getDeleteMarkerVersionId());
$this->assertEquals('demo.jpg', $list[2]->getKey());
$this->assertEquals('', $list[2]->getVersionId());
$this->assertEquals('', $list[2]->getDeleteMarker());
$this->assertEquals('', $list[2]->getDeleteMarkerVersionId());
$response = new ResponseCore(array(), $this->validXml4, 200);
$result = new DeleteObjectVersionsResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$list = $result->getData();
$this->assertEquals(3, count($list));
$this->assertEquals('multipart/.data', $list[0]->getKey());
$this->assertEquals('', $list[0]->getVersionId());
$this->assertEquals('', $list[0]->getDeleteMarker());
$this->assertEquals('', $list[0]->getDeleteMarkerVersionId());
$this->assertEquals('test/.jpg', $list[1]->getKey());
$this->assertEquals('', $list[1]->getVersionId());
$this->assertEquals('', $list[1]->getDeleteMarker());
$this->assertEquals('', $list[1]->getDeleteMarkerVersionId());
$this->assertEquals('demo/.jpg', $list[2]->getKey());
$this->assertEquals('', $list[2]->getVersionId());
$this->assertEquals('', $list[2]->getDeleteMarker());
$this->assertEquals('', $list[2]->getDeleteMarkerVersionId());
}
public function testParseNullXml()
{
$response = new ResponseCore(array(), "", 200);
$result = new DeleteObjectVersionsResult($response);
$list = $result->getData();
$this->assertEquals(0, count($list));
}
public function testParseInvalidXml()
{
$response = new ResponseCore(array(), $this->invalidXml, 200);
$result = new DeleteObjectVersionsResult($response);
$list = $result->getData();
$this->assertEquals(0, count($list));
}
}

View File

@ -0,0 +1,95 @@
<?php
namespace OSS\Tests;
use OSS\Result\GetBucketEncryptionResult;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
class GetBucketEncryptionResultTest extends \PHPUnit_Framework_TestCase
{
private $validXml = <<<BBBB
<?xml version="1.0" ?>
<ServerSideEncryptionRule>
<ApplyServerSideEncryptionByDefault>
<SSEAlgorithm>AES256</SSEAlgorithm>
<KMSMasterKeyID></KMSMasterKeyID>
</ApplyServerSideEncryptionByDefault>
</ServerSideEncryptionRule>
BBBB;
private $validXml1 = <<<BBBB
<?xml version="1.0" ?>
<ServerSideEncryptionRule>
<ApplyServerSideEncryptionByDefault>
<SSEAlgorithm>KMS</SSEAlgorithm>
<KMSMasterKeyID>kms-id</KMSMasterKeyID>
</ApplyServerSideEncryptionByDefault>
</ServerSideEncryptionRule>
BBBB;
private $validXml2 = <<<BBBB
<?xml version="1.0" ?>
<ServerSideEncryptionRule>
<ApplyServerSideEncryptionByDefault>
<SSEAlgorithm>KMS</SSEAlgorithm>
</ApplyServerSideEncryptionByDefault>
</ServerSideEncryptionRule>
BBBB;
private $invalidXml = <<<BBBB
<?xml version="1.0" ?>
<ServerSideEncryptionRule>
</ServerSideEncryptionRule>
BBBB;
public function testParseValidXml()
{
$response = new ResponseCore(array(), $this->validXml, 200);
$result = new GetBucketEncryptionResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$config = $result->getData();
$this->assertEquals("AES256", $config->getSSEAlgorithm());
$this->assertEquals("", $config->getKMSMasterKeyID());
$response = new ResponseCore(array(), $this->validXml1, 200);
$result = new GetBucketEncryptionResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$config = $result->getData();
$this->assertEquals("KMS", $config->getSSEAlgorithm());
$this->assertEquals("kms-id", $config->getKMSMasterKeyID());
$response = new ResponseCore(array(), $this->validXml2, 200);
$result = new GetBucketEncryptionResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$config = $result->getData();
$this->assertEquals("KMS", $config->getSSEAlgorithm());
$this->assertEquals(null, $config->getKMSMasterKeyID());
}
public function testParseNullXml()
{
$response = new ResponseCore(array(), "", 200);
$result = new GetBucketEncryptionResult($response);
$config = $result->getData();
$this->assertEquals(null, $config->getSSEAlgorithm());
$this->assertEquals(null, $config->getKMSMasterKeyID());
}
public function testParseInvalidXml()
{
$response = new ResponseCore(array(), $this->invalidXml, 200);
$result = new GetBucketEncryptionResult($response);
$config = $result->getData();
$this->assertEquals(null, $config->getSSEAlgorithm());
$this->assertEquals(null, $config->getKMSMasterKeyID());
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace OSS\Tests;
use OSS\Result\GetBucketRequestPaymentResult;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
class GetBucketRequestPaymentResultTest extends \PHPUnit_Framework_TestCase
{
private $validXml = <<<BBBB
<?xml version="1.0" ?>
<RequestPaymentConfiguration>
<Payer>Requester</Payer>
</RequestPaymentConfiguration>
BBBB;
private $validXml2 = <<<BBBB
<?xml version="1.0" ?>
<RequestPaymentConfiguration>
<Payer>BucketOwner</Payer>
</RequestPaymentConfiguration>
BBBB;
private $invalidXml = <<<BBBB
<?xml version="1.0" ?>
<RequestPaymentConfiguration>
</RequestPaymentConfiguration>
BBBB;
public function testParseValidXml()
{
$response = new ResponseCore(array(), $this->validXml, 200);
$result = new GetBucketRequestPaymentResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$payer = $result->getData();
$this->assertEquals("Requester", $payer);
$response = new ResponseCore(array(), $this->validXml2, 200);
$result = new GetBucketRequestPaymentResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$payer = $result->getData();
$this->assertEquals("BucketOwner", $payer);
}
public function testParseNullXml()
{
$response = new ResponseCore(array(), "", 200);
$result = new GetBucketRequestPaymentResult($response);
$payer = $result->getData();
$this->assertEquals(null, $payer);
}
public function testParseInvalidXml()
{
$response = new ResponseCore(array(), $this->invalidXml, 200);
$result = new GetBucketRequestPaymentResult($response);
$payer = $result->getData();
$this->assertEquals(null, $payer);
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace OSS\Tests;
use OSS\Result\GetBucketStatResult;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
class GetBucketStatResultTest extends \PHPUnit_Framework_TestCase
{
private $validXml = <<<BBBB
<?xml version="1.0" ?>
<BucketStat>
<Storage>100</Storage>
<ObjectCount>200</ObjectCount>
<MultipartUploadCount>10</MultipartUploadCount>
</BucketStat>
BBBB;
private $invalidXml = <<<BBBB
<?xml version="1.0" ?>
<BucketStat>
</BucketStat>
BBBB;
public function testParseValidXml()
{
$response = new ResponseCore(array(), $this->validXml, 200);
$result = new GetBucketStatResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$stat = $result->getData();
$this->assertEquals(100, $stat->getStorage());
$this->assertEquals(200, $stat->getObjectCount());
$this->assertEquals(10, $stat->getMultipartUploadCount());
}
public function testParseNullXml()
{
$response = new ResponseCore(array(), "", 200);
$result = new GetBucketStatResult($response);
$stat = $result->getData();
$this->assertEquals(0, $stat->getStorage());
$this->assertEquals(0, $stat->getObjectCount());
$this->assertEquals(0, $stat->getMultipartUploadCount());
}
public function testParseInvalidXml()
{
$response = new ResponseCore(array(), $this->invalidXml, 200);
$result = new GetBucketStatResult($response);
$stat = $result->getData();
$this->assertEquals(0, $stat->getStorage());
$this->assertEquals(0, $stat->getObjectCount());
$this->assertEquals(0, $stat->getMultipartUploadCount());
}
}

View File

@ -0,0 +1,77 @@
<?php
namespace OSS\Tests;
use OSS\Result\GetBucketTagsResult;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
class GetBucketTagsResultTest extends \PHPUnit_Framework_TestCase
{
private $validXml = <<<BBBB
<?xml version="1.0" ?>
<Tagging>
<TagSet>
<Tag>
<Key>testa</Key>
<Value>value1-test</Value>
</Tag>
<Tag>
<Key>testb</Key>
<Value>value2-test</Value>
</Tag>
</TagSet>
</Tagging>
BBBB;
private $invalidXml = <<<BBBB
<?xml version="1.0" ?>
<Tagging>
</Tagging>
BBBB;
private $invalidXml2 = <<<BBBB
<?xml version="1.0" ?>
<Tagging>
<TagSet>
</TagSet>
</Tagging>
BBBB;
public function testParseValidXml()
{
$response = new ResponseCore(array(), $this->validXml, 200);
$result = new GetBucketTagsResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$config = $result->getData();
$this->assertEquals(2, count($config->getTags()));
$this->assertEquals("testa", $config->getTags()[0]->getKey());
$this->assertEquals("value1-test", $config->getTags()[0]->getValue());
$this->assertEquals("testb", $config->getTags()[1]->getKey());
$this->assertEquals("value2-test", $config->getTags()[1]->getValue());
}
public function testParseNullXml()
{
$response = new ResponseCore(array(), "", 200);
$result = new GetBucketTagsResult($response);
$config = $result->getData();
$this->assertEquals(0, count($config->getTags()));
}
public function testParseInvalidXml()
{
$response = new ResponseCore(array(), $this->invalidXml, 200);
$result = new GetBucketTagsResult($response);
$config = $result->getData();
$this->assertEquals(0, count($config->getTags()));
$response = new ResponseCore(array(), $this->invalidXml2, 200);
$result = new GetBucketTagsResult($response);
$config = $result->getData();
$this->assertEquals(0, count($config->getTags()));
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace OSS\Tests;
use OSS\Result\GetBucketWormResult;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
class GetBucketWormResultTest extends \PHPUnit_Framework_TestCase
{
private $validXml = <<<BBBB
<?xml version="1.0" ?>
<WormConfiguration>
<WormId>ID1</WormId>
<State>Locked</State>
<RetentionPeriodInDays>1</RetentionPeriodInDays>
<CreationDate>2018-08-14T15:50:32</CreationDate>
</WormConfiguration>
BBBB;
private $validXml2 = <<<BBBB
<?xml version="1.0" ?>
<WormConfiguration>
<WormId>ID2</WormId>
<State>InProgress</State>
<RetentionPeriodInDays>10</RetentionPeriodInDays>
<CreationDate>2018-09-14T15:50:32</CreationDate>
</WormConfiguration>
BBBB;
private $invalidXml = <<<BBBB
<?xml version="1.0" ?>
<WormConfiguration>
</WormConfiguration>
BBBB;
public function testParseValidXml()
{
$response = new ResponseCore(array(), $this->validXml, 200);
$result = new GetBucketWormResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$config = $result->getData();
$this->assertEquals("ID1", $config->getWormId());
$this->assertEquals("Locked", $config->getState());
$this->assertEquals(1, $config->getDay());
$this->assertEquals("2018-08-14T15:50:32", $config->getCreationDate());
$response = new ResponseCore(array(), $this->validXml2, 200);
$result = new GetBucketWormResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$config = $result->getData();
$this->assertEquals("ID2", $config->getWormId());
$this->assertEquals("InProgress", $config->getState());
$this->assertEquals(10, $config->getDay());
$this->assertEquals("2018-09-14T15:50:32", $config->getCreationDate());
}
public function testParseNullXml()
{
$response = new ResponseCore(array(), "", 200);
$result = new GetBucketWormResult($response);
$config = $result->getData();
$this->assertEquals("", $config->getWormId());
$this->assertEquals("", $config->getState());
$this->assertEquals(0, $config->getDay());
$this->assertEquals("", $config->getCreationDate());
}
public function testParseInvalidXml()
{
$response = new ResponseCore(array(), $this->invalidXml, 200);
$result = new GetBucketWormResult($response);
$config = $result->getData();
$this->assertEquals("", $config->getWormId());
$this->assertEquals("", $config->getState());
$this->assertEquals(0, $config->getDay());
$this->assertEquals("", $config->getCreationDate());
}
}

View File

@ -71,15 +71,15 @@ BBBB;
); );
$errorBody = <<< BBBB $errorBody = <<< BBBB
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Error> <Error>
<Code>NoSuchBucket</Code> <Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist.</Message> <Message>The specified bucket does not exist.</Message>
<RequestId>566B870D207FB3044302EB0A</RequestId> <RequestId>566B870D207FB3044302EB0A</RequestId>
<HostId>hello.oss-test.aliyun-inc.com</HostId> <HostId>hello.oss-test.aliyun-inc.com</HostId>
<BucketName>hello</BucketName> <BucketName>hello</BucketName>
</Error> </Error>
BBBB; BBBB;
$response = new ResponseCore($errorHeader, $errorBody, 403); $response = new ResponseCore($errorHeader, $errorBody, 403);
try { try {
new ListBucketsResult($response); new ListBucketsResult($response);
@ -94,4 +94,74 @@ BBBB;
$this->assertEquals($e->getDetails(), $errorBody); $this->assertEquals($e->getDetails(), $errorBody);
} }
} }
public function testParseXml2()
{
$xml = <<<BBBB
<?xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult>
<Owner>
<ID>ut_test_put_bucket</ID>
<DisplayName>ut_test_put_bucket</DisplayName>
</Owner>
<Buckets>
<Bucket>
<CreationDate>2015-12-17T18:12:43.000Z</CreationDate>
<ExtranetEndpoint>oss-cn-shanghai.aliyuncs.com</ExtranetEndpoint>
<IntranetEndpoint>oss-cn-shanghai-internal.aliyuncs.com</IntranetEndpoint>
<Location>oss-cn-shanghai</Location>
<Name>app-base-oss</Name>
<Region>cn-shanghai</Region>
<StorageClass>Standard</StorageClass>
</Bucket>
<Bucket>
<CreationDate>2014-12-25T11:21:04.000Z</CreationDate>
<ExtranetEndpoint>oss-cn-hangzhou.aliyuncs.com</ExtranetEndpoint>
<IntranetEndpoint>oss-cn-hangzhou-internal.aliyuncs.com</IntranetEndpoint>
<Location>oss-cn-hangzhou</Location>
<Name>atestleo23</Name>
<Region>cn-hangzhou</Region>
<StorageClass>IA</StorageClass>
</Bucket>
<Bucket>
<CreationDate>2014-12-25T11:21:04.000Z</CreationDate>
<Location>oss-cn-hangzhou</Location>
<Name>atestleo23</Name>
</Bucket>
</Buckets>
</ListAllMyBucketsResult>
BBBB;
$response = new ResponseCore(array(), $xml, 200);
$result = new ListBucketsResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$bucketListInfo = $result->getData();
$this->assertEquals(3, count($bucketListInfo->getBucketList()));
$this->assertEquals("2015-12-17T18:12:43.000Z", $bucketListInfo->getBucketList()[0]->getCreateDate());
$this->assertEquals("oss-cn-shanghai", $bucketListInfo->getBucketList()[0]->getLocation());
$this->assertEquals("app-base-oss", $bucketListInfo->getBucketList()[0]->getName());
$this->assertEquals("oss-cn-shanghai.aliyuncs.com", $bucketListInfo->getBucketList()[0]->getExtranetEndpoint());
$this->assertEquals("oss-cn-shanghai-internal.aliyuncs.com", $bucketListInfo->getBucketList()[0]->getIntranetEndpoint());
$this->assertEquals("cn-shanghai", $bucketListInfo->getBucketList()[0]->getRegion());
$this->assertEquals("Standard", $bucketListInfo->getBucketList()[0]->getStorageClass());
$this->assertEquals("2014-12-25T11:21:04.000Z", $bucketListInfo->getBucketList()[1]->getCreateDate());
$this->assertEquals("oss-cn-hangzhou", $bucketListInfo->getBucketList()[1]->getLocation());
$this->assertEquals("atestleo23", $bucketListInfo->getBucketList()[1]->getName());
$this->assertEquals("oss-cn-hangzhou.aliyuncs.com", $bucketListInfo->getBucketList()[1]->getExtranetEndpoint());
$this->assertEquals("oss-cn-hangzhou-internal.aliyuncs.com", $bucketListInfo->getBucketList()[1]->getIntranetEndpoint());
$this->assertEquals("cn-hangzhou", $bucketListInfo->getBucketList()[1]->getRegion());
$this->assertEquals("IA", $bucketListInfo->getBucketList()[1]->getStorageClass());
$this->assertEquals("2014-12-25T11:21:04.000Z", $bucketListInfo->getBucketList()[2]->getCreateDate());
$this->assertEquals("oss-cn-hangzhou", $bucketListInfo->getBucketList()[2]->getLocation());
$this->assertEquals("atestleo23", $bucketListInfo->getBucketList()[2]->getName());
$this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getExtranetEndpoint());
$this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getIntranetEndpoint());
$this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getRegion());
$this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getStorageClass());
}
} }

View File

@ -0,0 +1,213 @@
<?php
namespace OSS\Tests;
use OSS\Result\ListObjectVersionsResult;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
class ListObjectVersionsResultTest extends \PHPUnit_Framework_TestCase
{
private $validXml = <<<BBBB
<?xml version="1.0" ?>
<ListVersionsResult>
<Name>oss-example</Name>
<Prefix></Prefix>
<KeyMarker>example</KeyMarker>
<VersionIdMarker>CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****</VersionIdMarker>
<MaxKeys>100</MaxKeys>
<Delimiter></Delimiter>
<IsTruncated>false</IsTruncated>
<DeleteMarker>
<Key>example</Key>
<VersionId>CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****</VersionId>
<IsLatest>false</IsLatest>
<LastModified>2019-04-09T07:27:28.000Z</LastModified>
<Owner>
<ID>1234512528586****</ID>
<DisplayName>12345125285864390</DisplayName>
</Owner>
</DeleteMarker>
<Version>
<Key>example</Key>
<VersionId>CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****</VersionId>
<IsLatest>false</IsLatest>
<LastModified>2019-04-09T07:27:28.000Z</LastModified>
<ETag>"250F8A0AE989679A22926A875F0A2****"</ETag>
<Type>Normal</Type>
<Size>93731</Size>
<StorageClass>Standard</StorageClass>
<Owner>
<ID>1234512528586****</ID>
<DisplayName>12345125285864390</DisplayName>
</Owner>
</Version>
<Version>
<Key>pic.jpg</Key>
<VersionId>CAEQMxiBgMCZov2D0BYiIDY4MDllOTc2YmY5MjQxMzdiOGI3OTlhNTU0ODIx****</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2019-04-09T07:27:28.000Z</LastModified>
<ETag>"3663F7B0B9D3153F884C821E7CF4****"</ETag>
<Type>Normal</Type>
<Size>574768</Size>
<StorageClass>IA</StorageClass>
<Owner>
<ID>1234512528586****</ID>
<DisplayName>12345125285864390</DisplayName>
</Owner>
</Version>
</ListVersionsResult>
BBBB;
private $validXml1 = <<<BBBB
<?xml version="1.0" ?>
<ListVersionsResult>
<Name>oss-example</Name>
<Prefix></Prefix>
<KeyMarker>example</KeyMarker>
<VersionIdMarker>CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****</VersionIdMarker>
<MaxKeys>100</MaxKeys>
<Delimiter></Delimiter>
<IsTruncated>false</IsTruncated>
<DeleteMarker>
<Key>example</Key>
<VersionId>CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****</VersionId>
<IsLatest>true</IsLatest>
<LastModified>2019-04-09T07:27:28.000Z</LastModified>
<Owner>
<ID>1234512528586****</ID>
<DisplayName>12345125285864390</DisplayName>
</Owner>
</DeleteMarker>
<DeleteMarker>
<Key>example-1</Key>
<VersionId>CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****</VersionId>
<LastModified>2019-04-09T07:27:28.000Z</LastModified>
<Owner>
<ID>1234512528586****</ID>
<DisplayName>12345125285864390</DisplayName>
</Owner>
</DeleteMarker>
<Version>
<Key>example-2</Key>
<VersionId>CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****</VersionId>
<LastModified>2019-04-09T07:27:28.000Z</LastModified>
<ETag>"250F8A0AE989679A22926A875F0A2****"</ETag>
<Type>Normal</Type>
<Size>93731</Size>
<StorageClass>Standard</StorageClass>
<Owner>
<ID>1234512528586****</ID>
<DisplayName>12345125285864390</DisplayName>
</Owner>
</Version>
</ListVersionsResult>
BBBB;
private $invalidXml = <<<BBBB
<?xml version="1.0" ?>
<ListVersionsResult>
</ListVersionsResult>
BBBB;
public function testParseValidXml()
{
$response = new ResponseCore(array(), $this->validXml, 200);
$result = new ListObjectVersionsResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$list = $result->getData();
$this->assertEquals(0, count($list->getPrefixList()));
$this->assertEquals(1, count($list->getDeleteMarkerList()));
$this->assertEquals(2, count($list->getObjectVersionList()));
$this->assertEquals('oss-example', $list->getBucketName());
$this->assertEquals('', $list->getPrefix());
$this->assertEquals('example', $list->getKeyMarker());
$this->assertEquals('CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****', $list->getVersionIdMarker());
$this->assertEquals(100, $list->getMaxKeys());
$this->assertEquals('', $list->getDelimiter());
$this->assertEquals('false', $list->getIsTruncated());
$deleteMarkerList = $list->getDeleteMarkerList();
$this->assertEquals('example', $deleteMarkerList[0]->getKey());
$this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $deleteMarkerList[0]->getVersionId());
$this->assertEquals('false', $deleteMarkerList[0]->getIsLatest());
$this->assertEquals('2019-04-09T07:27:28.000Z', $deleteMarkerList[0]->getLastModified());
$objectVersionList = $list->getObjectVersionList();
$this->assertEquals('example', $objectVersionList[0]->getKey());
$this->assertEquals('CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****', $objectVersionList[0]->getVersionId());
$this->assertEquals('false', $objectVersionList[0]->getIsLatest());
$this->assertEquals('2019-04-09T07:27:28.000Z', $objectVersionList[0]->getLastModified());
$this->assertEquals('"250F8A0AE989679A22926A875F0A2****"', $objectVersionList[0]->getETag());
$this->assertEquals('Normal', $objectVersionList[0]->getType());
$this->assertEquals(93731, $objectVersionList[0]->getSize());
$this->assertEquals('Standard', $objectVersionList[0]->getStorageClass());
$this->assertEquals('pic.jpg', $objectVersionList[1]->getKey());
$this->assertEquals('CAEQMxiBgMCZov2D0BYiIDY4MDllOTc2YmY5MjQxMzdiOGI3OTlhNTU0ODIx****', $objectVersionList[1]->getVersionId());
$this->assertEquals('true', $objectVersionList[1]->getIsLatest());
$this->assertEquals('2019-04-09T07:27:28.000Z', $objectVersionList[1]->getLastModified());
$this->assertEquals('"3663F7B0B9D3153F884C821E7CF4****"', $objectVersionList[1]->getETag());
$this->assertEquals('Normal', $objectVersionList[1]->getType());
$this->assertEquals(574768, $objectVersionList[1]->getSize());
$this->assertEquals('IA', $objectVersionList[1]->getStorageClass());
$response = new ResponseCore(array(), $this->validXml1, 200);
$result = new ListObjectVersionsResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$list = $result->getData();
$this->assertEquals(0, count($list->getPrefixList()));
$this->assertEquals(2, count($list->getDeleteMarkerList()));
$this->assertEquals(1, count($list->getObjectVersionList()));
$this->assertEquals('oss-example', $list->getBucketName());
$this->assertEquals('', $list->getPrefix());
$this->assertEquals('example', $list->getKeyMarker());
$this->assertEquals('CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****', $list->getVersionIdMarker());
$this->assertEquals(100, $list->getMaxKeys());
$this->assertEquals('', $list->getDelimiter());
$this->assertEquals('false', $list->getIsTruncated());
$deleteMarkerList = $list->getDeleteMarkerList();
$this->assertEquals('example', $deleteMarkerList[0]->getKey());
$this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $deleteMarkerList[0]->getVersionId());
$this->assertEquals('true', $deleteMarkerList[0]->getIsLatest());
$this->assertEquals('2019-04-09T07:27:28.000Z', $deleteMarkerList[0]->getLastModified());
$this->assertEquals('example-1', $deleteMarkerList[1]->getKey());
$this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $deleteMarkerList[1]->getVersionId());
$this->assertEquals('', $deleteMarkerList[1]->getIsLatest());
$this->assertEquals('2019-04-09T07:27:28.000Z', $deleteMarkerList[1]->getLastModified());
$objectVersionList = $list->getObjectVersionList();
$this->assertEquals('example-2', $objectVersionList[0]->getKey());
$this->assertEquals('CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****', $objectVersionList[0]->getVersionId());
$this->assertEquals('', $objectVersionList[0]->getIsLatest());
$this->assertEquals('2019-04-09T07:27:28.000Z', $objectVersionList[0]->getLastModified());
$this->assertEquals('"250F8A0AE989679A22926A875F0A2****"', $objectVersionList[0]->getETag());
$this->assertEquals('Normal', $objectVersionList[0]->getType());
$this->assertEquals(93731, $objectVersionList[0]->getSize());
$this->assertEquals('Standard', $objectVersionList[0]->getStorageClass());
}
public function testParseNullXml()
{
$response = new ResponseCore(array(), "", 200);
$result = new ListObjectVersionsResult($response);
$list = $result->getData();
}
public function testParseInvalidXml()
{
$response = new ResponseCore(array(), $this->invalidXml, 200);
$result = new ListObjectVersionsResult($response);
$stat = $result->getData();
}
}

View File

@ -4,11 +4,13 @@ namespace OSS\Tests;
require_once __DIR__ . '/Common.php'; require_once __DIR__ . '/Common.php';
use OSS\Core\OssException;
use OSS\Model\LiveChannelInfo; use OSS\Model\LiveChannelInfo;
use OSS\Model\LiveChannelListInfo; use OSS\Model\LiveChannelListInfo;
use OSS\Model\LiveChannelConfig; use OSS\Model\LiveChannelConfig;
use OSS\Model\GetLiveChannelStatus; use OSS\Model\GetLiveChannelStatus;
use OSS\Model\GetLiveChannelHistory; use OSS\Model\GetLiveChannelHistory;
use OSS\Model\LiveChannelHistory;
class LiveChannelXmlTest extends \PHPUnit_Framework_TestCase class LiveChannelXmlTest extends \PHPUnit_Framework_TestCase
{ {
@ -139,7 +141,7 @@ BBBB;
} }
public function testLiveChannelHistory() public function testGetLiveChannelHistory()
{ {
$history = new GetLiveChannelHistory(); $history = new GetLiveChannelHistory();
$history->parseFromXml($this->history); $history->parseFromXml($this->history);
@ -246,4 +248,30 @@ BBBB;
$this->assertEquals('http://bucket.oss-cn-hangzhou.aliyuncs.com/2/播放列表.m3u8', $plays[0]); $this->assertEquals('http://bucket.oss-cn-hangzhou.aliyuncs.com/2/播放列表.m3u8', $plays[0]);
} }
public function testLiveChannelHistory()
{
$xml = "<LiveRecord><StartTime>2013-11-24T14:25:31.000Z</StartTime><EndTime>2013-11-24T15:25:31.000Z</EndTime><RemoteAddr>10.101.194.148:56861</RemoteAddr></LiveRecord>";
$history = new LiveChannelHistory();
$history->parseFromXml($xml);
$this->assertEquals('2013-11-24T14:25:31.000Z', $history->getStartTime());
$this->assertEquals('2013-11-24T15:25:31.000Z', $history->getEndTime());
$this->assertEquals('10.101.194.148:56861', $history->getRemoteAddr());
}
public function testGetLiveChannelHistorySerializeToXml()
{
try {
$history = new GetLiveChannelHistory ();
$history->serializeToXml();
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
if (strpos($e, "Not implemented.") == false)
{
$this->assertTrue(false);
}
}
}
} }

View File

@ -4,12 +4,12 @@ namespace OSS\Tests;
require_once __DIR__ . '/Common.php'; require_once __DIR__ . '/Common.php';
class ObjectAclTest extends \PHPUnit_Framework_TestCase class ObjectAclTest extends TestOssClientBase
{ {
public function testGetSet() public function testGetSet()
{ {
$client = Common::getOssClient(); $client = $this->ossClient;
$bucket = Common::getBucketName(); $bucket = $this->bucket;
$object = 'test/object-acl'; $object = 'test/object-acl';
$client->deleteObject($bucket, $object); $client->deleteObject($bucket, $object);

View File

@ -0,0 +1,63 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
use OSS\Model\ServerSideEncryptionConfig;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketEncryptionTest extends TestOssClientBase
{
public function testBucket()
{
$config = new ServerSideEncryptionConfig("AES256");
try {
$this->ossClient->putBucketEncryption($this->bucket, $config);
} catch (OssException $e) {
var_dump($e->getMessage());
$this->assertTrue(false);
}
try {
Common::waitMetaSync();
$config2 = $this->ossClient->getBucketEncryption($this->bucket);
$this->assertEquals($config->serializeToXml(), $config2->serializeToXml());
$this->assertEquals("AES256", $config2->getSSEAlgorithm());
$this->assertEquals(null, $config2->getKMSMasterKeyID());
} catch (OssException $e) {
$this->assertTrue(false);
}
$config = new ServerSideEncryptionConfig("KMS", "kms-id");
try {
$this->ossClient->putBucketEncryption($this->bucket, $config);
} catch (OssException $e) {
var_dump($e->getMessage());
$this->assertTrue(false);
}
try {
Common::waitMetaSync();
$config2 = $this->ossClient->getBucketEncryption($this->bucket);
$this->assertEquals($config->serializeToXml(), $config2->serializeToXml());
$this->assertEquals("KMS", $config2->getSSEAlgorithm());
$this->assertEquals("kms-id", $config2->getKMSMasterKeyID());
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
Common::waitMetaSync();
$this->ossClient->deleteBucketEncryption($this->bucket);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
Common::waitMetaSync();
$config2 = $this->ossClient->getBucketEncryption($this->bucket);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals("NoSuchServerSideEncryptionRule", $e->getErrorCode());
}
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketInfoTest extends TestOssClientBase
{
public function testBucketInfo()
{
try {
$info = $this->ossClient->getBucketInfo($this->bucket);
$this->assertEquals($this->bucket, $info->getName());
$this->assertEquals("Standard", $info->getStorageClass());
} catch (OssException $e) {
$this->assertTrue(false);
}
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketPolicyTest extends TestOssClientBase
{
public function testBucket()
{
$policy_str = <<< BBBB
{
"Version":"1",
"Statement":[
{
"Action":[
"oss:PutObject",
"oss:GetObject"
],
"Effect":"Deny",
"Principal":["1234567890"],
"Resource":["acs:oss:*:1234567890:*/*"]
}
]
}
BBBB;
try {
$this->ossClient->deleteBucketPolicy($this->bucket);
$policy = $this->ossClient->getBucketPolicy($this->bucket);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
$this->assertEquals("NoSuchBucketPolicy", $e->getErrorCode());
}
try {
$this->ossClient->putBucketPolicy($this->bucket, $policy_str);
$policy = $this->ossClient->getBucketPolicy($this->bucket);
$this->assertEquals($policy_str, $policy);
$this->ossClient->deleteBucketPolicy($this->bucket);
} catch (OssException $e) {
$this->assertTrue(false);
}
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
use OSS\Model\RequestPaymentConfig;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketRequestPaymentTest extends TestOssClientBase
{
public function testBucket()
{
try {
Common::waitMetaSync();
$payer = $this->ossClient->getBucketRequestPayment($this->bucket);
$this->assertEquals("BucketOwner", $payer);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->ossClient->putBucketRequestPayment($this->bucket, "Requester");
} catch (OssException $e) {
var_dump($e->getMessage());
$this->assertTrue(false);
}
try {
Common::waitMetaSync();
$payer = $this->ossClient->getBucketRequestPayment($this->bucket);
$this->assertEquals("Requester", $payer);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->ossClient->putBucketRequestPayment($this->bucket, "BucketOwner");
} catch (OssException $e) {
var_dump($e->getMessage());
$this->assertTrue(false);
}
try {
Common::waitMetaSync();
$payer = $this->ossClient->getBucketRequestPayment($this->bucket);
$this->assertEquals("BucketOwner", $payer);
} catch (OssException $e) {
$this->assertTrue(false);
}
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketStatTestTest extends TestOssClientBase
{
public function testBucketStat()
{
try {
$content = "hello";
$this->ossClient->putObject($this->bucket, "name-1.txt", $content);
$this->ossClient->putObject($this->bucket, "name-2.txt", $content);
$this->ossClient->putObject($this->bucket, "name-3.txt", $content);
$object = "multipart-test.txt";
$upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object);
Common::waitMetaSync();
Common::waitMetaSync();
Common::waitMetaSync();
$stat = $this->ossClient->getBucketStat($this->bucket);
$this->assertEquals(3, $stat->getObjectCount());
$this->assertEquals(15, $stat->getStorage());
$this->assertEquals(1, $stat->getMultipartUploadCount());
} catch (OssException $e) {
$this->assertTrue(false);
}
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
use OSS\Model\TaggingConfig;
use OSS\Model\Tag;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketTagsTest extends TestOssClientBase
{
public function testBucket()
{
try {
Common::waitMetaSync();
$config = $this->ossClient->getBucketTags($this->bucket);
$this->assertEquals(0, count($config->getTags()));
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$config = new TaggingConfig();
$config->addTag(new Tag("key1", "value1"));
$config->addTag(new Tag("key2", "value2"));
$config->addTag(new Tag("key3", "value3"));
$this->ossClient->putBucketTags($this->bucket, $config);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
Common::waitMetaSync();
$config2 = $this->ossClient->getBucketTags($this->bucket);
$this->assertEquals(3, count($config2->getTags()));
$this->assertEquals("key1", $config2->getTags()[0]->getKey());
$this->assertEquals("value1", $config2->getTags()[0]->getValue());
$this->assertEquals("key2", $config2->getTags()[1]->getKey());
$this->assertEquals("value2", $config2->getTags()[1]->getValue());
$this->assertEquals("key3", $config2->getTags()[2]->getKey());
$this->assertEquals("value3", $config2->getTags()[2]->getValue());
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
Common::waitMetaSync();
//del key1, key3
$tags = array();
$tags[] = new Tag("key1", "value1");
$tags[] = new Tag("key3", "value3");
$this->ossClient->deleteBucketTags($this->bucket, $tags);
$config2 = $this->ossClient->getBucketTags($this->bucket);
$this->assertEquals(1, count($config2->getTags()));
$this->assertEquals("key2", $config2->getTags()[0]->getKey());
$this->assertEquals("value2", $config2->getTags()[0]->getValue());
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
Common::waitMetaSync();
//del all
$this->ossClient->deleteBucketTags($this->bucket);
$config2 = $this->ossClient->getBucketTags($this->bucket);
$this->assertEquals(0, count($config2->getTags()));
} catch (OssException $e) {
$this->assertTrue(false);
}
}
}

View File

@ -10,6 +10,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketTest extends TestOssClientBase class OssClientBucketTest extends TestOssClientBase
{ {
private $standardBucket;
private $iaBucket; private $iaBucket;
private $archiveBucket; private $archiveBucket;
@ -80,12 +81,31 @@ class OssClientBucketTest extends TestOssClientBase
$this->assertEquals($result, 'testcontent'); $this->assertEquals($result, 'testcontent');
} }
public function testCreateBucketWithInvalidStorageType()
{
try {
$options = array(
OssClient::OSS_STORAGE => 'unknown'
);
$this->ossClient->createBucket('bucket-name', OssClient::OSS_ACL_TYPE_PRIVATE, $options);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
if (strpos($e, "storage name is invalid") == false)
{
$this->assertTrue(false);
}
}
}
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->iaBucket = 'ia-' . $this->bucket; $this->iaBucket = 'ia-' . $this->bucket;
$this->archiveBucket = 'archive-' . $this->bucket; $this->archiveBucket = 'archive-' . $this->bucket;
$this->standardBucket = 'standard-' . $this->bucket;
$options = array( $options = array(
OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_IA OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_IA
); );
@ -97,6 +117,12 @@ class OssClientBucketTest extends TestOssClientBase
); );
$this->ossClient->createBucket($this->archiveBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); $this->ossClient->createBucket($this->archiveBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options);
$options = array(
OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_STANDARD
);
$this->ossClient->createBucket($this->standardBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options);
} }
public function tearDown() public function tearDown()
@ -109,5 +135,6 @@ class OssClientBucketTest extends TestOssClientBase
$this->ossClient->deleteObject($this->archiveBucket, $object); $this->ossClient->deleteObject($this->archiveBucket, $object);
$this->ossClient->deleteBucket($this->iaBucket); $this->ossClient->deleteBucket($this->iaBucket);
$this->ossClient->deleteBucket($this->archiveBucket); $this->ossClient->deleteBucket($this->archiveBucket);
$this->ossClient->deleteBucket($this->standardBucket);
} }
} }

View File

@ -0,0 +1,40 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketVersioningTest extends TestOssClientBase
{
public function testBucket()
{
try {
Common::waitMetaSync();
$status = $this->ossClient->getBucketVersioning($this->bucket);
$this->assertEquals(null, $status);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->ossClient->putBucketVersioning($this->bucket, "Enabled");
Common::waitMetaSync();
$status = $this->ossClient->getBucketVersioning($this->bucket);
$this->assertEquals("Enabled", $status);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->ossClient->putBucketVersioning($this->bucket, "Suspended");
Common::waitMetaSync();
$status = $this->ossClient->getBucketVersioning($this->bucket);
$this->assertEquals("Suspended", $status);
} catch (OssException $e) {
$this->assertTrue(false);
}
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketWormTest extends TestOssClientBase
{
public function testBucket()
{
try {
$wormId = $this->ossClient->initiateBucketWorm($this->bucket, 30);
$config = $this->ossClient->getBucketWorm($this->bucket);
$this->assertEquals($wormId, $config->getWormId());
$this->assertEquals("InProgress", $config->getState());
$this->assertEquals(30, $config->getDay());
$this->ossClient->abortBucketWorm($this->bucket);
$wormId = $this->ossClient->initiateBucketWorm($this->bucket, 60);
$this->ossClient->completeBucketWorm($this->bucket, $wormId);
$config = $this->ossClient->getBucketWorm($this->bucket);
$this->ossClient->ExtendBucketWorm($this->bucket, $wormId, 120);
$config = $this->ossClient->getBucketWorm($this->bucket);
$this->assertEquals($wormId, $config->getWormId());
$this->assertEquals("Locked", $config->getState());
$this->assertEquals(120, $config->getDay());
} catch (OssException $e) {
$this->assertTrue(false);
}
}
}

View File

@ -6,7 +6,7 @@ require_once __DIR__ . '/Common.php';
use OSS\OssClient; use OSS\OssClient;
class OssClinetImageTest extends \PHPUnit_Framework_TestCase class OssClinetImageTest extends TestOssClientBase
{ {
private $bucketName; private $bucketName;
private $client; private $client;
@ -16,21 +16,22 @@ class OssClinetImageTest extends \PHPUnit_Framework_TestCase
public function setUp() public function setUp()
{ {
$this->client = Common::getOssClient(); parent::setUp();
$this->bucketName = 'php-sdk-test-bucket-image-' . strval(rand(0, 10000));
$this->client->createBucket($this->bucketName); $this->client = $this->ossClient;
Common::waitMetaSync(); $this->bucketName = $this->bucket;
$this->local_file = "example.jpg"; $this->local_file = "example.jpg";
$this->object = "oss-example.jpg"; $this->object = "oss-example.jpg";
$this->download_file = "image.jpg"; $this->download_file = "image.jpg";
Common::waitMetaSync();
$this->client->uploadFile($this->bucketName, $this->object, $this->local_file); $this->client->uploadFile($this->bucketName, $this->object, $this->local_file);
} }
public function tearDown() public function tearDown()
{ {
$this->client->deleteObject($this->bucketName, $this->object); parent::tearDown();
$this->client->deleteBucket($this->bucketName); unlink($this->download_file);
} }
public function testImageResize() public function testImageResize()
@ -89,6 +90,47 @@ class OssClinetImageTest extends \PHPUnit_Framework_TestCase
$this->check($options, 100, 100, 3267, 'jpg'); $this->check($options, 100, 100, 3267, 'jpg');
} }
public function testProcesObject()
{
$object = 'process-object.jpg';
$process = 'image/resize,m_fixed,w_100,h_100'.
'|sys/saveas'.
',o_'.$this->base64url_encode($object).
',b_'.$this->base64url_encode($this->bucketName);
$result = $this->client->processObject($this->bucketName, $this->object, $process);
$this->assertTrue(stripos($result, '"object": "process-object.jpg",') > 0);
$this->assertTrue(stripos($result, '"status": "OK"') > 0);
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $this->download_file,
);
$this->client->getObject($this->bucketName, $object, $options);
$array = getimagesize($this->download_file);
$this->assertEquals(100, $array[0]);
$this->assertEquals(100, $array[1]);
$this->assertEquals(2, $array[2]);
//without bucket
$object = 'process-object-1.jpg';
$process = 'image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ'.
'|sys/saveas'.
',o_'.$this->base64url_encode($object);
$result = $this->client->processObject($this->bucketName, $this->object, $process);
$this->assertTrue(stripos($result, '"object": "process-object-1.jpg",') > 0);
$this->assertTrue(stripos($result, '"status": "OK"') > 0);
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $this->download_file,
);
$this->client->getObject($this->bucketName, $object, $options);
$array = getimagesize($this->download_file);
$this->assertEquals(400, $array[0]);
$this->assertEquals(267, $array[1]);
$this->assertEquals(2, $array[2]);
}
private function check($options, $width, $height, $size, $type) private function check($options, $width, $height, $size, $type)
{ {
$this->client->getObject($this->bucketName, $this->object, $options); $this->client->getObject($this->bucketName, $this->object, $options);
@ -97,4 +139,9 @@ class OssClinetImageTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($height, $array[1]); $this->assertEquals($height, $array[1]);
$this->assertEquals($type === 'jpg' ? 2 : 3, $array[2]);//2 <=> jpg $this->assertEquals($type === 'jpg' ? 2 : 3, $array[2]);//2 <=> jpg
} }
private function base64url_encode($data)
{
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
} }

View File

@ -0,0 +1,184 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
use OSS\OssClient;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientListObjectsTest extends TestOssClientBase
{
public function testListObjectsDefault()
{
try {
$listObjectInfo = $this->ossClient->listObjects($this->bucket);
$objectList = $listObjectInfo->getObjectList();
$prefixList = $listObjectInfo->getPrefixList();
$this->assertNotNull($objectList);
$this->assertNotNull($prefixList);
$this->assertTrue(is_array($objectList));
$this->assertTrue(is_array($prefixList));
$this->assertEquals((2), count($objectList));
$this->assertEquals(4, count($prefixList));
$this->assertEquals('file++00', $objectList[0]->getKey());
$this->assertEquals('file++01', $objectList[1]->getKey());
$this->assertEquals('folder/', $prefixList[0]->getPrefix());
$this->assertEquals('sub++/', $prefixList[1]->getPrefix());
$this->assertEquals('test/', $prefixList[2]->getPrefix());
$this->assertEquals('work/', $prefixList[3]->getPrefix());
} catch (OssException $e) {
$this->assertTrue(false);
}
}
public function testListObjectsWithPrefix()
{
/**
* List the files in your bucket.
*/
$prefix = 'folder/';
$delimiter = '';
$next_marker = '';
$maxkeys = 1000;
$options = array(
'delimiter' => $delimiter,
'prefix' => $prefix,
'max-keys' => $maxkeys,
'marker' => $next_marker,
);
try {
$listObjectInfo = $this->ossClient->listObjects($this->bucket, $options);
$objectList = $listObjectInfo->getObjectList();
$prefixList = $listObjectInfo->getPrefixList();
$this->assertNotNull($objectList);
$this->assertNotNull($prefixList);
$this->assertTrue(is_array($objectList));
$this->assertTrue(is_array($prefixList));
$this->assertEquals(12, count($objectList));
$this->assertEquals(0, count($prefixList));
$this->assertEquals('folder/00', $objectList[0]->getKey());
$this->assertEquals('folder/01', $objectList[1]->getKey());
$this->assertEquals('folder/11', $objectList[11]->getKey());
} catch (OssException $e) {
$this->assertTrue(false);
}
}
public function testListObjectsWithMaxKeysAndMarker()
{
$count = 0;
$nextMarker = '';
while (true) {
try {
$options = array(
'delimiter' => '',
'marker' => $nextMarker,
'max-keys' => 2,
);
$listObjectInfo = $this->ossClient->listObjects($this->bucket, $options);
} catch (OssException $e) {
$this->assertTrue(false);
}
$nextMarker = $listObjectInfo->getNextMarker();
$listObject = $listObjectInfo->getObjectList();
$count += count($listObject);
$this->assertEquals(2, count($listObject));
if ($listObjectInfo->getIsTruncated() !== "true") {
break;
}
}
$this->assertEquals(12 + 8 + 5 + 3 + 2, $count);
}
public function testListObjectsWithMarker()
{
$count = 0;
$nextMarker = 'h';
while (true) {
try {
$options = array(
'delimiter' => '',
'marker' => $nextMarker,
'max-keys' => 1,
);
$listObjectInfo = $this->ossClient->listObjects($this->bucket, $options);
} catch (OssException $e) {
$this->assertTrue(false);
}
$nextMarker = $listObjectInfo->getNextMarker();
$listObject = $listObjectInfo->getObjectList();
$count += count($listObject);
$this->assertEquals(1, count($listObject));
if ($listObjectInfo->getIsTruncated() !== "true") {
break;
}
}
$this->assertEquals(8 + 5 + 3, $count);
$nextMarker = 'h';
try {
$options = array(
'delimiter' => '',
'marker' => $nextMarker,
'max-keys' => 5,
);
$listObjectInfo = $this->ossClient->listObjects($this->bucket, $options);
} catch (OssException $e) {
$this->assertTrue(false);
}
$nextMarker = $listObjectInfo->getNextMarker();
$listObject = $listObjectInfo->getObjectList();
$this->assertEquals('test/01', $nextMarker);
$this->assertEquals(5, count($listObject));
$this->assertEquals("true", $listObjectInfo->getIsTruncated());
}
public function setUp()
{
parent::setUp();
//folder
for ($i = 0; $i < 12; $i++) {
$key = 'folder/'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
}
//test
for ($i = 0; $i < 8; $i++) {
$key = 'test/'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
}
//work
for ($i = 0; $i < 5; $i++) {
$key = 'work/'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
}
//sub++
for ($i = 0; $i < 3; $i++) {
$key = 'sub++/'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
}
//file++
for ($i = 0; $i < 2; $i++) {
$key = 'file++'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
}
}
public function tearDown()
{
parent::tearDown();
}
}

View File

@ -108,6 +108,54 @@ class OssClientMultipartUploadTest extends TestOssClientBase
$this->assertEquals($this->ossClient->getObject($this->bucket, $copiedObject), file_get_contents(__FILE__)); $this->assertEquals($this->ossClient->getObject($this->bucket, $copiedObject), file_get_contents(__FILE__));
} }
public function testCopyPartWithRange()
{
$object = "mpu/multipart-test.txt";
$copiedObject = "mpu/multipart-test.txt.range.copied";
$this->ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__));
/**
* step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id
*/
try {
$upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object);
} catch (OssException $e) {
$this->assertFalse(true);
}
/*
* step 2. uploadPartCopy
*/
$copyId = 1;
$options = array(
'start' => 0,
'end' => 3,
);
$eTag = $this->ossClient->uploadPartCopy($this->bucket, $copiedObject, $this->bucket, $object, $copyId, $upload_id, $options);
$upload_parts[] = array(
'PartNumber' => $copyId,
'ETag' => $eTag,
);
try {
$listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id);
$this->assertNotNull($listPartsInfo);
} catch (OssException $e) {
$this->assertTrue(false);
}
/**
* step 3.
*/
try {
$this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts);
} catch (OssException $e) {
var_dump($e->getMessage());
$this->assertTrue(false);
}
$this->assertEquals($this->ossClient->getObject($this->bucket, $copiedObject), file_get_contents(__FILE__));
$this->assertEquals($this->ossClient->getObject($this->bucket, $object), '<?ph');
}
public function testAbortMultipartUpload() public function testAbortMultipartUpload()
{ {
$object = "mpu/multipart-test.txt"; $object = "mpu/multipart-test.txt";
@ -159,7 +207,7 @@ class OssClientMultipartUploadTest extends TestOssClientBase
} }
try { try {
$listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id, array('max-parts' => 100));
$this->assertNotNull($listPartsInfo); $this->assertNotNull($listPartsInfo);
} catch (OssException $e) { } catch (OssException $e) {
$this->assertTrue(false); $this->assertTrue(false);
@ -184,7 +232,7 @@ class OssClientMultipartUploadTest extends TestOssClientBase
$numOfMultipartUpload2 = 0; $numOfMultipartUpload2 = 0;
try { try {
$listMultipartUploadInfo = $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, $options); $listMultipartUploadInfo = $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, array('max-uploads' => 1000));
$this->assertNotNull($listMultipartUploadInfo); $this->assertNotNull($listMultipartUploadInfo);
$numOfMultipartUpload2 = count($listMultipartUploadInfo->getUploads()); $numOfMultipartUpload2 = count($listMultipartUploadInfo->getUploads());
} catch (OssException $e) { } catch (OssException $e) {
@ -300,6 +348,52 @@ class OssClientMultipartUploadTest extends TestOssClientBase
} }
} }
public function testPutObjectByMultipartUploadWithOSS_LENGTH()
{
$object = "mpu/multipart-test-length.txt";
$file = __FILE__;
try {
$upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object);
$options = array(OssClient::OSS_LENGTH => 4, OssClient::OSS_UPLOAD_ID => $upload_id);
$this->ossClient->multiuploadFile($this->bucket, $object, $file, $options);
$this->assertEquals($this->ossClient->getObject($this->bucket, $object), '<?ph');
} catch (OssException $e) {
$this->assertFalse(true);
}
}
public function testPutObjectByMultipartUploadWithOSS_CONTENT_LENGTH()
{
$object = "mpu/multipart-test-content-length.txt";
$file = __FILE__;
try {
$upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object);
$options = array(OssClient::OSS_CONTENT_LENGTH => 4, OssClient::OSS_UPLOAD_ID => $upload_id);
$this->ossClient->multiuploadFile($this->bucket, $object, $file, $options);
$this->assertEquals($this->ossClient->getObject($this->bucket, $object), '<?ph');
} catch (OssException $e) {
$this->assertFalse(true);
}
}
public function testPutObjectByMultipartUploadWithException()
{
$object = "mpu/multipart-test-exception.txt";
$file = "";
try {
$this->ossClient->multiuploadFile($this->bucket, $object, $file);
} catch (OssException $e) {
$this->assertTrue(true);
if (strpos($e, "parameter invalid, file is empty") == false)
{
$this->assertTrue(true);
}
}
}
public function testListMultipartUploads() public function testListMultipartUploads()
{ {
$options = null; $options = null;
@ -310,4 +404,20 @@ class OssClientMultipartUploadTest extends TestOssClientBase
$this->assertFalse(true); $this->assertFalse(true);
} }
} }
public function testCompleteMultipartUploadWithException()
{
$object = "mpu/multipart-test-complete.txt";
$uploadId = "uploadId";
try {
$listMultipartUploadInfo = $this->ossClient->completeMultipartUpload($this->bucket, $object, $uploadId, null);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
if (strpos($e, "listParts must be array type") == false)
{
$this->assertTrue(false);
}
}
}
} }

View File

@ -0,0 +1,471 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
use OSS\OssClient;
use OSS\Model\RestoreConfig;
use OSS\Model\TaggingConfig;
use OSS\Model\Tag;
use OSS\Core\OssUtil;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientObjectRequestPaymentTest extends TestOssClientBase
{
private $payerClient;
public function testPayerClientWithoutRequester()
{
try {
$this->payerClient->listObjects($this->bucket);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->createObjectDir($this->bucket, 'folder/');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->putObject($this->bucket, 'object', 'content');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->putSymlink($this->bucket, 'symlink', 'default-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->getSymlink($this->bucket, 'default-symlink');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->uploadFile($this->bucket, 'file-object', __FILE__);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->appendObject($this->bucket, 'append-object', 'content', 0);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->appendObject($this->bucket, 'append-file', __FILE__, 0);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->copyObject($this->bucket, 'default-object', $this->bucket, 'copy-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->getObjectMeta($this->bucket, 'default-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
try {
$this->payerClient->getSimplifiedObjectMeta($this->bucket, 'default-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
try {
$this->payerClient->deleteObject($this->bucket, 'default-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->getObject($this->bucket, 'default-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->doesObjectExist($this->bucket, 'default-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
try {
$this->payerClient->restoreObject($this->bucket, 'default-ia-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$config = new TaggingConfig();
$config->addTag(new Tag("key1", "value1"));
$this->payerClient->putObjectTagging($this->bucket, 'default-object', $config);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->getObjectTagging($this->bucket, 'default-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->deleteObjectTagging($this->bucket, 'default-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->initiateMultipartUpload($this->bucket, 'mup-object');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
$uploadId= $this->ossClient->initiateMultipartUpload($this->bucket, 'mup-object');
try {
$this->payerClient->listParts($this->bucket, 'mup-object', $uploadId);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->abortMultipartUpload($this->bucket, 'mup-object', $uploadId);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->listMultipartUploads($this->bucket);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
try {
$this->payerClient->multiuploadFile($this->bucket, 'mup-file', __FILE__);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertEquals('AccessDenied', $e->getErrorCode());
}
}
public function testObjectOperationsWithRequester()
{
$options = array(
OssClient::OSS_HEADERS => array(
OssClient::OSS_REQUEST_PAYER => 'requester',
));
try {
$this->payerClient->listObjects($this->bucket, $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->createObjectDir($this->bucket, 'folder/', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->putObject($this->bucket, 'object', 'content', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->putSymlink($this->bucket, 'symlink', 'default-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->getSymlink($this->bucket, 'default-symlink', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->uploadFile($this->bucket, 'file-object', __FILE__, $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->appendObject($this->bucket, 'append-object', 'content', 0, $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->appendObject($this->bucket, 'append-file', __FILE__, 0, $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->copyObject($this->bucket, 'default-object', $this->bucket, 'copy-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->getObjectMeta($this->bucket, 'default-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->getSimplifiedObjectMeta($this->bucket, 'default-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->getObject($this->bucket, 'default-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->putObject($this->bucket, 'test-object', 'content', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->deleteObject($this->bucket, 'test-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->doesObjectExist($this->bucket, 'default-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
$ia_options = array(
OssClient::OSS_HEADERS => array(
'x-oss-storage-class' => 'Archive',
));
$this->ossClient->putObject($this->bucket, 'default-Archive-object', 'content', $ia_options);
try {
$this->payerClient->restoreObject($this->bucket, 'default-Archive-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$config = new TaggingConfig();
$config->addTag(new Tag("key1", "value1"));
$this->payerClient->putObjectTagging($this->bucket, 'default-object', $config, $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->getObjectTagging($this->bucket, 'default-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->payerClient->deleteObjectTagging($this->bucket, 'default-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
}
public function testMultipartOperationsWithRequester()
{
$options = array(
OssClient::OSS_HEADERS => array(
OssClient::OSS_REQUEST_PAYER => 'requester',
));
$object = "mpu/multipart-test.txt";
/**
* step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id
*/
try {
$upload_id = $this->payerClient->initiateMultipartUpload($this->bucket, $object, $options);
} catch (OssException $e) {
$this->assertFalse(true);
}
/*
* step 2. 上传分片
*/
$part_size = 1 * 1024 * 1024;
$upload_file = __FILE__;
$upload_filesize = filesize($upload_file);
$pieces = $this->payerClient->generateMultiuploadParts($upload_filesize, $part_size);
$response_upload_part = array();
$upload_position = 0;
$is_check_md5 = false;
foreach ($pieces as $i => $piece) {
$from_pos = $upload_position + (integer)$piece[OssClient::OSS_SEEK_TO];
$to_pos = (integer)$piece[OssClient::OSS_LENGTH] + $from_pos - 1;
$up_options = array(
OssClient::OSS_FILE_UPLOAD => $upload_file,
OssClient::OSS_PART_NUM => ($i + 1),
OssClient::OSS_SEEK_TO => $from_pos,
OssClient::OSS_LENGTH => $to_pos - $from_pos + 1,
OssClient::OSS_CHECK_MD5 => $is_check_md5,
OssClient::OSS_HEADERS => array(
OssClient::OSS_REQUEST_PAYER => 'requester',
),
);
//2. 将每一分片上传到OSS
try {
$response_upload_part[] = $this->ossClient->uploadPart($this->bucket, $object, $upload_id, $up_options);
} catch (OssException $e) {
$this->assertFalse(true);
}
}
$upload_parts = array();
foreach ($response_upload_part as $i => $eTag) {
$upload_parts[] = array(
'PartNumber' => ($i + 1),
'ETag' => $eTag,
);
}
try {
$listPartsInfo = $this->payerClient->listParts($this->bucket, $object, $upload_id, $options);
$this->assertNotNull($listPartsInfo);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$uploads = $this->payerClient->listMultipartUploads($this->bucket, $options);
$this->assertNotNull($uploads);
} catch (OssException $e) {
$this->assertTrue(false);
}
/**
* step 3.
*/
try {
$this->payerClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts, $options);
} catch (OssException $e) {
$this->assertTrue(false);
}
}
public function testMiscOperationsWithRequester()
{
//use multipart
$options = array(
OssClient::OSS_PART_SIZE => 1,
OssClient::OSS_HEADERS => array(
OssClient::OSS_REQUEST_PAYER => 'requester',
));
$bigFileName = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp";
OssUtil::generateFile($bigFileName, 256 * 1024);
$object = 'mpu/multipart-bigfile-test.tmp';
try {
$this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, $options);
} catch (OssException $e) {
$this->assertFalse(true);
}
//use uploadfile
$options = array(
OssClient::OSS_PART_SIZE => 1024*1024,
OssClient::OSS_HEADERS => array(
OssClient::OSS_REQUEST_PAYER => 'requester',
));
try {
$this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, $options);
} catch (OssException $e) {
$this->assertFalse(true);
}
unlink($bigFileName);
}
public function setUp()
{
parent::setUp();
$this->payerClient = new OssClient(
getenv('OSS_PAYER_ACCESS_KEY_ID'),
getenv('OSS_PAYER_ACCESS_KEY_SECRET'),
getenv('OSS_ENDPOINT'), false);
$policy = '{"Version":"1","Statement":[{"Action":["oss:*"],"Effect": "Allow",'.
'"Principal":["' . getenv('OSS_PAYER_UID') . '"],'.
'"Resource": ["acs:oss:*:*:' . $this->bucket . '","acs:oss:*:*:' . $this->bucket . '/*"]}]}';
$this->ossClient->putBucketPolicy($this->bucket, $policy);
$this->ossClient->putBucketRequestPayment($this->bucket, 'Requester');
$this->ossClient->putObject($this->bucket, "default-object", "");
$this->ossClient->putSymlink($this->bucket, "default-symlink", "default-object");
}
public function tearDown()
{
parent::tearDown();
}
}

View File

@ -0,0 +1,160 @@
<?php
namespace OSS\Tests;
use OSS\OssClient;
use OSS\Core\OssUtil;
use OSS\Core\OssException;
use OSS\Model\TaggingConfig;
use OSS\Model\Tag;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientObjectTaggingTest extends TestOssClientBase
{
public function testObjectTagging()
{
$object = "object-tagging.txt";
$content = "hello world";
try {
$this->ossClient->putObject($this->bucket, $object, $content);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$config = $this->ossClient->getObjectTagging($this->bucket, $object);
$this->assertEquals(0, count($config->getTags()));
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$config = new TaggingConfig();
$config->addTag(new Tag("key1", "value1"));
$config->addTag(new Tag("key2", "value2"));
$config->addTag(new Tag("key3", "value3"));
$this->ossClient->putObjectTagging($this->bucket, $object, $config);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$config2 = $this->ossClient->getObjectTagging($this->bucket, $object);
$this->assertEquals(3, count($config2->getTags()));
$this->assertEquals("key1", $config2->getTags()[0]->getKey());
$this->assertEquals("value1", $config2->getTags()[0]->getValue());
$this->assertEquals("key2", $config2->getTags()[1]->getKey());
$this->assertEquals("value2", $config2->getTags()[1]->getValue());
$this->assertEquals("key3", $config2->getTags()[2]->getKey());
$this->assertEquals("value3", $config2->getTags()[2]->getValue());
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$this->ossClient->deleteObjectTagging($this->bucket, $object);
$config2 = $this->ossClient->getObjectTagging($this->bucket, $object);
$this->assertEquals(0, count($config2->getTags()));
} catch (OssException $e) {
$this->assertTrue(false);
}
}
public function testPutObjectTaggingFromHeader()
{
$object = "object-tagging-header.txt";
$content = "hello world";
try {
$options = array(
OssClient::OSS_HEADERS => array(
'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3',
));
$this->ossClient->putObject($this->bucket, $object, $content, $options);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$config2 = $this->ossClient->getObjectTagging($this->bucket, $object);
$this->assertEquals(3, count($config2->getTags()));
$this->assertEquals("key1", $config2->getTags()[0]->getKey());
$this->assertEquals("value1", $config2->getTags()[0]->getValue());
$this->assertEquals("key2", $config2->getTags()[1]->getKey());
$this->assertEquals("value2", $config2->getTags()[1]->getValue());
$this->assertEquals("key3", $config2->getTags()[2]->getKey());
$this->assertEquals("value3", $config2->getTags()[2]->getValue());
} catch (OssException $e) {
$this->assertTrue(false);
}
}
public function testAppendObjectTaggingFromHeader()
{
$object = "append-object-tagging-header.txt";
$content_array = array('Hello OSS', 'Hi OSS', 'OSS OK');
try {
$options = array(
OssClient::OSS_HEADERS => array(
'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3',
));
$position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0, $options);
$this->assertEquals($position, strlen($content_array[0]));
$position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position);
$this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]));
$position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2])));
$this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2]));
$config2 = $this->ossClient->getObjectTagging($this->bucket, $object);
$this->assertEquals(3, count($config2->getTags()));
$this->assertEquals("key1", $config2->getTags()[0]->getKey());
$this->assertEquals("value1", $config2->getTags()[0]->getValue());
$this->assertEquals("key2", $config2->getTags()[1]->getKey());
$this->assertEquals("value2", $config2->getTags()[1]->getValue());
$this->assertEquals("key3", $config2->getTags()[2]->getKey());
$this->assertEquals("value3", $config2->getTags()[2]->getValue());
} catch (OssException $e) {
$this->assertFalse(true);
}
}
public function testMultipartUploadTaggingFromHeader()
{
$file = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp";
OssUtil::generateFile($file, 110 * 1024);
$object = "mpu-object-tagging-header.txt";
$options = array(
OssClient::OSS_CHECK_MD5 => true,
OssClient::OSS_PART_SIZE => 1,
OssClient::OSS_HEADERS => array(
'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3',
),
);
try {
$this->ossClient->multiuploadFile($this->bucket, $object, $file, $options);
$config2 = $this->ossClient->getObjectTagging($this->bucket, $object);
$this->assertEquals(3, count($config2->getTags()));
$this->assertEquals("key1", $config2->getTags()[0]->getKey());
$this->assertEquals("value1", $config2->getTags()[0]->getValue());
$this->assertEquals("key2", $config2->getTags()[1]->getKey());
$this->assertEquals("value2", $config2->getTags()[1]->getValue());
$this->assertEquals("key3", $config2->getTags()[2]->getKey());
$this->assertEquals("value3", $config2->getTags()[2]->getValue());
} catch (OssException $e) {
$this->assertFalse(true);
}
unlink($file);
}
}

View File

@ -88,7 +88,6 @@ class OssClientObjectTest extends TestOssClientBase
'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT',
'Cache-Control' => 'no-cache', 'Cache-Control' => 'no-cache',
'Content-Disposition' => 'attachment;filename=oss_download.log', 'Content-Disposition' => 'attachment;filename=oss_download.log',
'Content-Encoding' => 'utf-8',
'Content-Language' => 'zh-CN', 'Content-Language' => 'zh-CN',
'x-oss-server-side-encryption' => 'AES256', 'x-oss-server-side-encryption' => 'AES256',
'x-oss-meta-self-define-title' => 'user define meta info', 'x-oss-meta-self-define-title' => 'user define meta info',
@ -328,12 +327,18 @@ class OssClientObjectTest extends TestOssClientBase
$this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object2)); $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object2));
$result = $this->ossClient->deleteObjects($this->bucket, $list); $result = $this->ossClient->deleteObjects($this->bucket, $list);
$this->assertEquals($list[1], $result[0]); $this->assertEquals($list[0], $result[0]);
$this->assertEquals($list[0], $result[1]); $this->assertEquals($list[1], $result[1]);
$result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => 'true')); $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => 'true'));
$this->assertEquals(array(), $result); $this->assertEquals(array(), $result);
$this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object2)); $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object2));
$this->ossClient->putObject($this->bucket, $object, $content);
$this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object));
$result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => true));
$this->assertEquals(array(), $result);
$this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object));
} catch (OssException $e) { } catch (OssException $e) {
$this->assertFalse(true); $this->assertFalse(true);
} }
@ -352,8 +357,8 @@ class OssClientObjectTest extends TestOssClientBase
$this->assertEquals($position, strlen($content_array[0])); $this->assertEquals($position, strlen($content_array[0]));
$position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position); $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position);
$this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]));
$position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position); $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2])));
$this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[1])); $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2]));
} catch (OssException $e) { } catch (OssException $e) {
$this->assertFalse(true); $this->assertFalse(true);
} }
@ -378,6 +383,16 @@ class OssClientObjectTest extends TestOssClientBase
$this->assertFalse(true); $this->assertFalse(true);
} }
/**
* Append the upload of invalid local files
*/
try {
$position = $this->ossClient->appendFile($this->bucket, $object, "invalid-file-path", 0);
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
/** /**
* Append the upload of local files * Append the upload of local files
*/ */
@ -590,6 +605,65 @@ class OssClientObjectTest extends TestOssClientBase
} }
} }
public function testGetSimplifiedObjectMeta()
{
$object = "oss-php-sdk-test/upload-test-object-name.txt";
try {
$objectMeta = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object);
$this->assertEquals(false, array_key_exists(strtolower('Content-Disposition'), $objectMeta));
$this->assertEquals(strlen(file_get_contents(__FILE__)), $objectMeta[strtolower('Content-Length')]);
$this->assertEquals(true, array_key_exists(strtolower('ETag'), $objectMeta));
$this->assertEquals(true, array_key_exists(strtolower('Last-Modified'), $objectMeta));
} catch (OssException $e) {
$this->assertFalse(true);
}
}
public function testUploadStream()
{
$object = "oss-php-sdk-test/put-from-stream.txt";
$options = array(OssClient::OSS_CHECK_MD5 => true);
$handle = fopen(__FILE__, 'rb');
/**
* Upload data to start MD5
*/
try {
$this->ossClient->uploadStream($this->bucket, $object, $handle, $options);
} catch (OssException $e) {
$this->assertFalse(true);
}
/**
* Check if the replication is the same
*/
try {
$content = $this->ossClient->getObject($this->bucket, $object);
$this->assertEquals($content, file_get_contents(__FILE__));
} catch (OssException $e) {
$this->assertFalse(true);
}
$object = "oss-php-sdk-test/put-from-stream-without-md5.txt";
$handle = fopen(__FILE__, 'rb');
try {
$this->ossClient->uploadStream($this->bucket, $object, $handle);
} catch (OssException $e) {
$this->assertFalse(true);
}
/**
* Check if the replication is the same
*/
try {
$content = $this->ossClient->getObject($this->bucket, $object);
$this->assertEquals($content, file_get_contents(__FILE__));
} catch (OssException $e) {
$this->assertFalse(true);
}
}
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -0,0 +1,610 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
use OSS\OssClient;
use OSS\Model\TaggingConfig;
use OSS\Model\Tag;
use OSS\Model\DeleteObjectInfo;
use OSS\Core\OssUtil;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientObjectVersioningTest extends TestOssClientBase
{
public function testObjectBasic()
{
$object = 'object';
$content1 = 'hello';
$content2 = 'hello world';
$ret1 = $this->ossClient->putObject($this->bucket, $object, $content1, array(OssClient::OSS_HEADERS => array('x-oss-object-acl' => 'public-read', 'x-oss-tagging' => 'key1=value1')));
$ret2 = $this->ossClient->putObject($this->bucket, $object, $content2, array(OssClient::OSS_HEADERS => array('x-oss-object-acl' => 'private', 'x-oss-tagging' => 'key2=value2')));
$this->assertTrue(isset($ret1[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertTrue(isset($ret2[OssClient::OSS_HEADER_VERSION_ID]));
$versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID];
$versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID];
//get object
$res = $this->ossClient->getObject($this->bucket, $object);
$res1 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$res2 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2));
$this->assertEquals($content1, $res1);
$this->assertEquals($content2, $res2);
$this->assertEquals($content2, $res);
//meta
$headers = $this->ossClient->getObjectMeta($this->bucket, $object);
$headers1 = $this->ossClient->getObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$headers2 = $this->ossClient->getObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2));
$this->assertTrue(isset($headers[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertTrue(isset($headers1[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertTrue(isset($headers2[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertEquals($versionId1, $headers1[OssClient::OSS_HEADER_VERSION_ID]);
$this->assertEquals($versionId2, $headers2[OssClient::OSS_HEADER_VERSION_ID]);
$this->assertEquals($versionId2, $headers[OssClient::OSS_HEADER_VERSION_ID]);
$sheaders = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object);
$sheaders1 = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$sheaders2 = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2));
$this->assertTrue(isset($sheaders[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertTrue(isset($sheaders1[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertTrue(isset($sheaders2[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertEquals($versionId1, $sheaders1[OssClient::OSS_HEADER_VERSION_ID]);
$this->assertEquals($versionId2, $sheaders2[OssClient::OSS_HEADER_VERSION_ID]);
$this->assertEquals($versionId2, $sheaders[OssClient::OSS_HEADER_VERSION_ID]);
//acl
$acl = $this->ossClient->getObjectAcl($this->bucket, $object);
$acl1 = $this->ossClient->getObjectAcl($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$acl2 = $this->ossClient->getObjectAcl($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2));
$this->assertEquals('public-read', $acl1);
$this->assertEquals('private', $acl2);
$this->assertEquals('private', $acl);
$this->ossClient->putObjectAcl($this->bucket, $object, 'public-read-write', array(OssClient::OSS_VERSION_ID => $versionId1));
$acl = $this->ossClient->getObjectAcl($this->bucket, $object);
$acl1 = $this->ossClient->getObjectAcl($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$this->assertEquals('public-read-write', $acl1);
$this->assertEquals('private', $acl);
//tagging
$tag = $this->ossClient->getObjectTagging($this->bucket, $object);
$tag1 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$tag2 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2));
$this->assertEquals(1, count($tag1->getTags()));
$this->assertEquals("key1", $tag1->getTags()[0]->getKey());
$this->assertEquals("value1", $tag1->getTags()[0]->getValue());
$this->assertEquals(1, count($tag2->getTags()));
$this->assertEquals("key2", $tag2->getTags()[0]->getKey());
$this->assertEquals("value2", $tag2->getTags()[0]->getValue());
$this->assertEquals(1, count($tag->getTags()));
$this->assertEquals("key2", $tag->getTags()[0]->getKey());
$this->assertEquals("value2", $tag->getTags()[0]->getValue());
$config = new TaggingConfig();
$config->addTag(new Tag("key11", "value11"));
$this->ossClient->putObjectTagging($this->bucket, $object, $config, array(OssClient::OSS_VERSION_ID => $versionId1));
$tag = $this->ossClient->getObjectTagging($this->bucket, $object);
$tag1 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$this->assertEquals(1, count($tag1->getTags()));
$this->assertEquals("key11", $tag1->getTags()[0]->getKey());
$this->assertEquals("value11", $tag1->getTags()[0]->getValue());
$this->assertEquals(1, count($tag->getTags()));
$this->assertEquals("key2", $tag->getTags()[0]->getKey());
$this->assertEquals("value2", $tag->getTags()[0]->getValue());
$this->ossClient->deleteObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$tag = $this->ossClient->getObjectTagging($this->bucket, $object);
$tag1 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$this->assertEquals(0, count($tag1->getTags()));
$this->assertEquals(1, count($tag->getTags()));
$this->assertEquals("key2", $tag->getTags()[0]->getKey());
$this->assertEquals("value2", $tag->getTags()[0]->getValue());
//delete
$dret = $this->ossClient->deleteObject($this->bucket, $object);
$this->assertTrue(isset($dret['x-oss-delete-marker']));
$this->assertTrue(isset($dret['x-oss-version-id']));
$this->assertEquals("true", $dret['x-oss-delete-marker']);
$this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object));
$this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)));
$this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)));
$dret1 = $this->ossClient->deleteObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$this->assertFalse(isset($dret1['x-oss-delete-marker']));
$this->assertTrue(isset($dret1['x-oss-version-id']));
$this->assertEquals($versionId1, $dret1['x-oss-version-id']);
$this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)));
$dret_ = $this->ossClient->deleteObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $dret['x-oss-version-id']));
$this->assertTrue(isset($dret_['x-oss-delete-marker']));
$this->assertTrue(isset($dret_['x-oss-version-id']));
$this->assertEquals($dret['x-oss-version-id'], $dret_['x-oss-version-id']);
$this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object));
}
public function testObjectSymlink()
{
$object1 = 'object-target-1';
$object2 = 'object-target-2';
$symlink = 'object-symlink';
$content1 = 'hello';
$content2 = 'hello world';
$ret1 = $this->ossClient->putObject($this->bucket, $object1, $content1);
$sym1 = $this->ossClient->putSymlink($this->bucket, $symlink, $object1);
$ret2 = $this->ossClient->putObject($this->bucket, $object2, $content2);
$sym2 = $this->ossClient->putSymlink($this->bucket, $symlink, $object2);
$this->assertTrue(isset($ret1[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertTrue(isset($ret2[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertTrue(isset($sym1[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertTrue(isset($sym2[OssClient::OSS_HEADER_VERSION_ID]));
$versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID];
$versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID];
$sym_versionId1 = $sym1[OssClient::OSS_HEADER_VERSION_ID];
$sym_versionId2 = $sym2[OssClient::OSS_HEADER_VERSION_ID];
$sym_ret = $this->ossClient->getSymlink($this->bucket, $symlink);
$sym_ret1 = $this->ossClient->getSymlink($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId1));
$sym_ret2 = $this->ossClient->getSymlink($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId2));
$this->assertTrue(isset($sym_ret['x-oss-version-id']));
$this->assertTrue(isset($sym_ret1['x-oss-version-id']));
$this->assertTrue(isset($sym_ret2['x-oss-version-id']));
$this->assertEquals($sym_versionId1, $sym_ret1['x-oss-version-id']);
$this->assertEquals($sym_versionId2, $sym_ret2['x-oss-version-id']);
$this->assertEquals($sym_versionId2, $sym_ret['x-oss-version-id']);
$res = $this->ossClient->getObject($this->bucket, $symlink);
$res1 = $this->ossClient->getObject($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId1));
$res2 = $this->ossClient->getObject($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId2));
$this->assertEquals($content1, $res1);
$this->assertEquals($content2, $res2);
$this->assertEquals($content2, $res);
}
public function testObjectCopy()
{
$object = 'copy-= +object';
$content1 = 'hello';
$content2 = 'hello world';
$to_bucket = $this->bucket;
$to_object = $object . '.copy';
$to_object1 = $object . '.copy1';
$to_object2 = $object . '.copy2';
$ret1 = $this->ossClient->putObject($this->bucket, $object, $content1);
$ret2 = $this->ossClient->putObject($this->bucket, $object, $content2);
$versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID];
$versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID];
$cret = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object);
$cret1 = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object1, array(OssClient::OSS_VERSION_ID => $versionId1));
$cret2 = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object2, array(OssClient::OSS_VERSION_ID => $versionId2));
$this->assertFalse(empty($cret1));
$this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($cret1[0]));
$this->assertEquals(trim($ret1['etag'], '"'), trim($cret1[1], '"'));
$this->assertTrue(isset($cret1['x-oss-version-id']));
$this->assertEquals($versionId1, $cret1['x-oss-copy-source-version-id']);
$this->assertFalse(empty($cret2));
$this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($cret2[0]));
$this->assertEquals(trim($ret2['etag'], '"'), trim($cret2[1], '"'));
$this->assertTrue(isset($cret2['x-oss-version-id']));
$this->assertEquals($versionId2, $cret2['x-oss-copy-source-version-id']);
$this->assertFalse(empty($cret));
$this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($cret[0]));
$this->assertEquals(trim($ret2['etag'], '"'), trim($cret[1], '"'));
$this->assertTrue(isset($cret2['x-oss-version-id']));
$this->assertEquals($versionId2, $cret['x-oss-copy-source-version-id']);
$res = $this->ossClient->getObject($this->bucket, $to_object);
$res1 = $this->ossClient->getObject($this->bucket, $to_object1);
$res2 = $this->ossClient->getObject($this->bucket, $to_object2);
$this->assertEquals($content1, $res1);
$this->assertEquals($content2, $res2);
$this->assertEquals($content2, $res);
}
public function testObjectRestore()
{
$object = 'retore-object';
$content1 = 'hello';
$content2 = 'hello world';
$ret1 = $this->ossClient->putObject($this->bucket, $object, $content1, array(OssClient::OSS_HEADERS => array('x-oss-storage-class' => 'Archive')));
$ret2 = $this->ossClient->putObject($this->bucket, $object, $content2);
$versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID];
$versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID];
try{
$this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
$this->assertTrue(false);
}catch (OssException $e){
$this->assertEquals('403', $e->getHTTPStatus());
$this->assertEquals('InvalidObjectState', $e->getErrorCode());
}
try{
$this->ossClient->restoreObject($this->bucket, $object);
$this->assertTrue(false);
}catch(OssException $e){
$this->assertEquals('400', $e->getHTTPStatus());
$this->assertEquals('OperationNotSupported', $e->getErrorCode());
}
$result = $this->ossClient->restoreObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
common::waitMetaSync();
$this->assertEquals('202', $result['info']['http_code']);
try{
$this->ossClient->restoreObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1));
}catch(OssException $e){
$this->assertEquals('409', $e->getHTTPStatus());
$this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode());
}
}
public function testObjectMultiPart()
{
$object_src = 'multi-= +object.src';
$content1 = 'hello';
$content2 = 'hello world';
$ret1 = $this->ossClient->putObject($this->bucket, $object_src, $content1);
$ret2 = $this->ossClient->putObject($this->bucket, $object_src, $content2);
$this->assertTrue(isset($ret1[OssClient::OSS_HEADER_VERSION_ID]));
$this->assertTrue(isset($ret2[OssClient::OSS_HEADER_VERSION_ID]));
$versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID];
$versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID];
//object
$object = "multi-object";
$upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object);
$copyId = 1;
$eTag = $this->ossClient->uploadPartCopy($this->bucket, $object_src, $this->bucket, $object, $copyId, $upload_id);
$upload_parts[] = array(
'PartNumber' => $copyId,
'ETag' => $eTag,
);
$ret = $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts);
//object-1
$object1 = "multi-object-1";
$upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object1);
$copyId = 1;
$eTag = $this->ossClient->uploadPartCopy($this->bucket, $object_src, $this->bucket, $object1, $copyId, $upload_id, array(OssClient::OSS_VERSION_ID => $versionId1));
$upload_parts1[] = array(
'PartNumber' => $copyId,
'ETag' => $eTag,
);
$ret1 = $this->ossClient->completeMultipartUpload($this->bucket, $object1, $upload_id, $upload_parts1);
//object-2
$object2 = "multi-object-2";
$upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object2);
$copyId = 1;
$eTag = $this->ossClient->uploadPartCopy($this->bucket, $object_src, $this->bucket, $object2, $copyId, $upload_id, array(OssClient::OSS_VERSION_ID => $versionId2));
$upload_parts2[] = array(
'PartNumber' => $copyId,
'ETag' => $eTag,
);
$ret2 = $this->ossClient->completeMultipartUpload($this->bucket, $object2, $upload_id, $upload_parts2);
$res = $this->ossClient->getObject($this->bucket, $object);
$res1 = $this->ossClient->getObject($this->bucket, $object1);
$res2 = $this->ossClient->getObject($this->bucket, $object2);
$this->assertEquals($content1, $res1);
$this->assertEquals($content2, $res2);
$this->assertEquals($content2, $res);
}
public function testObjectMisc()
{
//use multipart
$options = array(
OssClient::OSS_PART_SIZE => 1,
);
$object = 'misc-object';
$smallFile1 = __DIR__ . DIRECTORY_SEPARATOR . "/smallfile1.tmp";
$smallFile2 = __DIR__ . DIRECTORY_SEPARATOR . "/smallfile2.tmp";
$bigFile1 = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile1.tmp";
$bigFile2 = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile2.tmp";
OssUtil::generateFile($smallFile1, 5);
OssUtil::generateFile($smallFile2, 10);
OssUtil::generateFile($bigFile1, 128 * 1024);
OssUtil::generateFile($bigFile2, 256 * 1024);
$sret1 = $this->ossClient->multiuploadFile($this->bucket, $object, $smallFile1, $options);
$sret2 = $this->ossClient->multiuploadFile($this->bucket, $object, $smallFile2, $options);
$bret1 = $this->ossClient->multiuploadFile($this->bucket, $object, $bigFile1, $options);
$bret2 = $this->ossClient->multiuploadFile($this->bucket, $object, $bigFile2, $options);
$res = $this->ossClient->getObject($this->bucket, $object);
$sres1 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $sret1['x-oss-version-id']));
$sres2 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $sret2['x-oss-version-id']));
$bres1 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $bret1['x-oss-version-id']));
$bres2 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $bret2['x-oss-version-id']));
$this->assertEquals(file_get_contents($smallFile1), $sres1);
$this->assertEquals(file_get_contents($smallFile2), $sres2);
$this->assertEquals(file_get_contents($bigFile1), $bres1);
$this->assertEquals(file_get_contents($bigFile2), $bres2);
$this->assertEquals(file_get_contents($bigFile2), $res);
unlink($smallFile1);
unlink($smallFile2);
unlink($bigFile1);
unlink($bigFile2);
}
public function testListObjects()
{
//folder
for ($i = 0; $i < 12; $i++) {
$key = 'folder/'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
$this->ossClient->putObject($this->bucket, $key, "content");
$this->ossClient->deleteObject($this->bucket, $key);
}
//test
for ($i = 0; $i < 8; $i++) {
$key = 'test/'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
$this->ossClient->deleteObject($this->bucket, $key);
$this->ossClient->putObject($this->bucket, $key, "content");
}
//work
for ($i = 0; $i < 5; $i++) {
$key = 'work/'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
}
//sub++
for ($i = 0; $i < 3; $i++) {
$key = 'sub++/'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
$this->ossClient->putObject($this->bucket, $key, "content");
$this->ossClient->putObject($this->bucket, $key, "content");
}
//file++
for ($i = 0; $i < 2; $i++) {
$key = 'file++'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
$this->ossClient->deleteObject($this->bucket, $key);
}
//list default
$result = $this->ossClient->listObjectVersions($this->bucket);
$versionList = $result->getObjectVersionList();
$deleteMarkerList = $result->getDeleteMarkerList();
$prefixList = $result->getPrefixList();
$this->assertNotNull($versionList);
$this->assertNotNull($deleteMarkerList);
$this->assertNotNull($prefixList);
$this->assertTrue(is_array($versionList));
$this->assertTrue(is_array($deleteMarkerList));
$this->assertTrue(is_array($prefixList));
$this->assertEquals(2, count($versionList));
$this->assertEquals(2, count($deleteMarkerList));
$this->assertEquals(4, count($prefixList));
$this->assertEquals('file++00', $versionList[0]->getKey());
$this->assertEquals('false', $versionList[0]->getIsLatest());
$this->assertEquals('file++01', $versionList[1]->getKey());
$this->assertEquals('false', $versionList[1]->getIsLatest());
$this->assertEquals('file++00', $deleteMarkerList[0]->getKey());
$this->assertEquals('true', $deleteMarkerList[0]->getIsLatest());
$this->assertEquals('file++01', $deleteMarkerList[1]->getKey());
$this->assertEquals('true', $deleteMarkerList[1]->getIsLatest());
$this->assertEquals('folder/', $prefixList[0]->getPrefix());
$this->assertEquals('sub++/', $prefixList[1]->getPrefix());
$this->assertEquals('test/', $prefixList[2]->getPrefix());
$this->assertEquals('work/', $prefixList[3]->getPrefix());
//list by prefix
$prefix = 'folder/';
$delimiter = '';
$next_marker = '';
$maxkeys = 1000;
$options = array(
'delimiter' => $delimiter,
'prefix' => $prefix,
'max-keys' => $maxkeys,
'key-marker' => $next_marker,
);
$result = $this->ossClient->listObjectVersions($this->bucket, $options);
$versionList = $result->getObjectVersionList();
$deleteMarkerList = $result->getDeleteMarkerList();
$prefixList = $result->getPrefixList();
$this->assertEquals(24, count($versionList));
$this->assertEquals(12, count($deleteMarkerList));
$this->assertEquals(0, count($prefixList));
$this->assertEquals('folder/00', $versionList[0]->getKey());
$this->assertEquals('folder/00', $versionList[1]->getKey());
$this->assertEquals('folder/00', $deleteMarkerList[0]->getKey());
$this->assertEquals('folder/01', $deleteMarkerList[1]->getKey());
//max-key & key-marker & version-id-marker
$count = 0;
$markerCount = 0;
$nextMarker = '';
$nextVersionIdMarker = '';
while (true) {
$options = array(
'delimiter' => '',
'key-marker' => $nextMarker,
'max-keys' => 1,
'version-id-marker' => $nextVersionIdMarker,
);
$result = $this->ossClient->listObjectVersions($this->bucket, $options);
$nextMarker = $result->getNextKeyMarker();
$nextVersionIdMarker = $result->getNextVersionIdMarker();
$count += count($result->getObjectVersionList());
$markerCount += count($result->getDeleteMarkerList());
$this->assertEquals(1, count($result->getObjectVersionList()) + count($result->getDeleteMarkerList()));
if ($result->getIsTruncated() !== "true") {
break;
}
}
$this->assertEquals(12*3 + 8*3 + 5 + 3*3 + 2*2, $count + $markerCount);
}
public function testDeleteObjects()
{
//deletes
for ($i = 0; $i < 5; $i++) {
$key = 'deletes/'. sprintf("%02d",$i);
$this->ossClient->putObject($this->bucket, $key, "content");
$this->ossClient->putObject($this->bucket, $key, "content");
}
$options = array(
'delimiter' => '',
'prefix' => 'deletes/',
'max-keys' => 1000,
);
$result = $this->ossClient->listObjects($this->bucket, $options);
$this->assertEquals(5, count($result->getObjectList()));
//delete without version-id
$objects = array();
for ($i = 0; $i < 5; $i++) {
$key = 'deletes/'. sprintf("%02d",$i);
$objects[] = new DeleteObjectInfo($key);
}
$dresult = $this->ossClient->deleteObjectVersions($this->bucket, $objects);
$this->assertEquals(5, count($dresult));
$this->assertEquals('deletes/00', $dresult[0]->getKey());
$this->assertEquals('true', $dresult[0]->getDeleteMarker());
$this->assertEquals('', $dresult[0]->getVersionId());
$this->assertFalse(empty($dresult[0]->getDeleteMarkerVersionId()));
$result = $this->ossClient->listObjects($this->bucket, $options);
$this->assertEquals(0, count($result->getObjectList()));
//delete by version-id
$vresult = $this->ossClient->listObjectVersions($this->bucket, $options);
$versions = $vresult->getObjectVersionList();
$deleteMarkerList = $vresult->getDeleteMarkerList();
$this->assertEquals(10, count($versions));
$this->assertEquals(5, count($deleteMarkerList));
$objects = array();
foreach ($versions as $obj) {
$objects[] = new DeleteObjectInfo($obj->getKey(), $obj->getVersionId());
}
$dresult = $this->ossClient->deleteObjectVersions($this->bucket, $objects);
$this->assertEquals(10, count($dresult));
$this->assertEquals('deletes/00', $dresult[0]->getKey());
$this->assertEquals('', $dresult[0]->getDeleteMarker());
$this->assertFalse(empty($dresult[0]->getVersionId()));
$this->assertTrue(empty($dresult[0]->getDeleteMarkerVersionId()));
$this->assertEquals('deletes/00', $dresult[1]->getKey());
$this->assertEquals('', $dresult[1]->getDeleteMarker());
$this->assertFalse(empty($dresult[1]->getVersionId()));
$this->assertTrue(empty($dresult[1]->getDeleteMarkerVersionId()));
$vresult = $this->ossClient->listObjectVersions($this->bucket, $options);
$versions = $vresult->getObjectVersionList();
$deleteMarkerList = $vresult->getDeleteMarkerList();
$this->assertEquals(0, count($versions));
$this->assertEquals(5, count($deleteMarkerList));
$objects = array();
foreach ($deleteMarkerList as $obj) {
$objects[] = new DeleteObjectInfo($obj->getKey(), $obj->getVersionId());
}
$dresult = $this->ossClient->deleteObjectVersions($this->bucket, $objects);
$this->assertEquals(5, count($dresult));
$this->assertEquals('deletes/00', $dresult[0]->getKey());
$this->assertEquals('true', $dresult[0]->getDeleteMarker());
$this->assertFalse(empty($dresult[1]->getVersionId()));
$this->assertFalse(empty($dresult[1]->getDeleteMarkerVersionId()));
$vresult = $this->ossClient->listObjectVersions($this->bucket, $options);
$versions = $vresult->getObjectVersionList();
$deleteMarkerList = $vresult->getDeleteMarkerList();
$this->assertEquals(0, count($versions));
$this->assertEquals(0, count($deleteMarkerList));
}
public function setUp()
{
parent::setUp();
$this->ossClient->putBucketVersioning($this->bucket, "Enabled");
}
public function tearDown()
{
if (!$this->ossClient->doesBucketExist($this->bucket)) {
return;
}
$this->ossClient->putBucketVersioning($this->bucket, "Suspended");
$result = $this->ossClient->listObjectVersions(
$this->bucket, array('max-keys' => 1000, 'delimiter' => ''));
$versions = $result->getObjectVersionList();
$deleteMarkers = $result->getDeleteMarkerList();
foreach ($versions as $obj) {
$options = array(
OssClient::OSS_VERSION_ID => $obj->getVersionId(),
);
$this->ossClient->deleteObject($this->bucket, $obj->getKey(), $options);
}
foreach ($deleteMarkers as $del) {
$options = array(
OssClient::OSS_VERSION_ID => $del->getVersionId(),
);
$this->ossClient->deleteObject($this->bucket, $del->getKey(), $options);
}
parent::tearDown();
}
}

View File

@ -4,6 +4,7 @@ namespace OSS\Tests;
use OSS\Core\OssException; use OSS\Core\OssException;
use OSS\OssClient; use OSS\OssClient;
use OSS\Model\RestoreConfig;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php'; require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
@ -63,6 +64,83 @@ class OssClientRestoreObjectTest extends TestOssClientBase
} }
} }
public function testColdArchiveRestoreObject()
{
$client = new OssClient(
getenv('OSS_ACCESS_KEY_ID'),
getenv('OSS_ACCESS_KEY_SECRET'),
'oss-ap-southeast-1.aliyuncs.com', false);
$bucket = $this->bucket . 'cold-archive';
$object = 'storage-object';
//create bucket
$options = array(
OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_COLDARCHIVE
);
$client->createBucket($bucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options);
//test with days
$client->putObject($bucket, $object,'testcontent');
try{
$client->getObject($bucket, $object);
$this->assertTrue(false);
}catch (OssException $e){
$this->assertEquals('403', $e->getHTTPStatus());
$this->assertEquals('InvalidObjectState', $e->getErrorCode());
}
$config = new RestoreConfig(5);
$resoptions = array(
OssClient::OSS_RESTORE_CONFIG => $config
);
try{
$client->restoreObject($bucket, $object, $resoptions);
}catch(OssException $e){
$this->assertTrue(false);
}
try{
$client->restoreObject($bucket, $object, $resoptions);
}catch(OssException $e){
$this->assertEquals('409', $e->getHTTPStatus());
$this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode());
}
//test with days & tier
$client->putObject($bucket, $object,'testcontent');
try{
$client->getObject($bucket, $object);
$this->assertTrue(false);
}catch (OssException $e){
$this->assertEquals('403', $e->getHTTPStatus());
$this->assertEquals('InvalidObjectState', $e->getErrorCode());
}
$config = new RestoreConfig(5, "Expedited");
$resoptions = array(
OssClient::OSS_RESTORE_CONFIG => $config
);
try{
$client->restoreObject($bucket, $object, $resoptions);
}catch(OssException $e){
$this->assertTrue(false);
}
try{
$client->restoreObject($bucket, $object, $resoptions);
}catch(OssException $e){
$this->assertEquals('409', $e->getHTTPStatus());
$this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode());
}
$client->deleteObject($bucket, $object);
$client->deleteBucket($bucket);
}
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@ -1,111 +1,167 @@
<?php <?php
namespace OSS\Tests; namespace OSS\Tests;
use OSS\Core\OssException; use OSS\Core\OssException;
use OSS\Http\RequestCore; use OSS\Http\RequestCore;
use OSS\Http\ResponseCore; use OSS\Http\ResponseCore;
use OSS\OssClient; use OSS\OssClient;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php'; require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientSignatureTest extends TestOssClientBase class OssClientSignatureTest extends TestOssClientBase
{ {
function testGetSignedUrlForGettingObject() function testGetSignedUrlForGettingObject()
{ {
$object = "a.file"; $object = "a.file";
$this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__));
$timeout = 3600; $timeout = 3600;
try { try {
$signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout); $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout);
} catch (OssException $e) { } catch (OssException $e) {
$this->assertFalse(true); $this->assertFalse(true);
} }
$request = new RequestCore($signedUrl); $request = new RequestCore($signedUrl);
$request->set_method('GET'); $request->set_method('GET');
$request->add_header('Content-Type', ''); $request->add_header('Content-Type', '');
$request->send_request(); $request->send_request();
$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());
$this->assertEquals(file_get_contents(__FILE__), $res->body); $this->assertEquals(file_get_contents(__FILE__), $res->body);
} }
public function testGetSignedUrlForPuttingObject() public function testGetSignedUrlForPuttingObject()
{ {
$object = "a.file"; $object = "a.file";
$timeout = 3600; $timeout = 3600;
try { try {
$signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT"); $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT");
$content = file_get_contents(__FILE__); $content = file_get_contents(__FILE__);
$request = new RequestCore($signedUrl); $request = new RequestCore($signedUrl);
$request->set_method('PUT'); $request->set_method('PUT');
$request->add_header('Content-Type', ''); $request->add_header('Content-Type', '');
$request->add_header('Content-Length', strlen($content)); $request->add_header('Content-Length', strlen($content));
$request->set_body($content); $request->set_body($content);
$request->send_request(); $request->send_request();
$res = new ResponseCore($request->get_response_header(), $res = new ResponseCore($request->get_response_header(),
$request->get_response_body(), $request->get_response_code()); $request->get_response_body(), $request->get_response_code());
$this->assertTrue($res->isOK()); $this->assertTrue($res->isOK());
} catch (OssException $e) { } catch (OssException $e) {
$this->assertFalse(true); $this->assertFalse(true);
} }
} }
public function testGetSignedUrlForPuttingObjectFromFile() public function testGetSignedUrlForPuttingObjectFromFile()
{ {
$file = __FILE__; $file = __FILE__;
$object = "a.file"; $object = "a.file";
$timeout = 3600; $timeout = 3600;
$options = array('Content-Type' => 'txt'); $options = array('Content-Type' => 'txt');
try { try {
$signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options);
$request = new RequestCore($signedUrl); $request = new RequestCore($signedUrl);
$request->set_method('PUT'); $request->set_method('PUT');
$request->add_header('Content-Type', 'txt'); $request->add_header('Content-Type', 'txt');
$request->set_read_file($file); $request->set_read_file($file);
$request->set_read_stream_size(filesize($file)); $request->set_read_stream_size(filesize($file));
$request->send_request(); $request->send_request();
$res = new ResponseCore($request->get_response_header(), $res = new ResponseCore($request->get_response_header(),
$request->get_response_body(), $request->get_response_code()); $request->get_response_body(), $request->get_response_code());
$this->assertTrue($res->isOK()); $this->assertTrue($res->isOK());
} catch (OssException $e) { } catch (OssException $e) {
$this->assertFalse(true); $this->assertFalse(true);
} }
} }
public function tearDown() public function testSignedUrlWithException()
{ {
$this->ossClient->deleteObject($this->bucket, "a.file"); $file = __FILE__;
parent::tearDown(); $object = "a.file";
} $timeout = 3600;
$options = array('Content-Type' => 'txt');
public function setUp() try {
{ $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "POST", $options);
parent::setUp(); $this->assertTrue(false);
/** } catch (OssException $e) {
* 上传本地变量到bucket $this->assertTrue(true);
*/ if (strpos($e, "method is invalid") == false)
$object = "a.file"; {
$content = file_get_contents(__FILE__); $this->assertTrue(false);
$options = array( }
OssClient::OSS_LENGTH => strlen($content), }
OssClient::OSS_HEADERS => array( }
'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT',
'Cache-Control' => 'no-cache', function testGetgenPreSignedUrlForGettingObject()
'Content-Disposition' => 'attachment;filename=oss_download.log', {
'Content-Encoding' => 'utf-8', $object = "a.file";
'Content-Language' => 'zh-CN', $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__));
'x-oss-server-side-encryption' => 'AES256', $expires = time() + 3600;
'x-oss-meta-self-define-title' => 'user define meta info', try {
), $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires);
); } catch (OssException $e) {
$this->assertFalse(true);
try { }
$this->ossClient->putObject($this->bucket, $object, $content, $options);
} catch (OssException $e) { $request = new RequestCore($signedUrl);
$this->assertFalse(true); $request->set_method('GET');
} $request->add_header('Content-Type', '');
} $request->send_request();
} $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());
$this->assertEquals(file_get_contents(__FILE__), $res->body);
}
function testGetgenPreSignedUrlVsSignedUrl()
{
$object = "object-vs.file";
$signedUrl1 = '245';
$signedUrl2 = '123';
$expiration = 0;
do {
usleep(500000);
$begin = time();
$expiration = time() + 3600;
$signedUrl1 = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expiration);
$signedUrl2 = $this->ossClient->signUrl($this->bucket, $object, 3600);
$end = time();
} while ($begin != $end);
$this->assertEquals($signedUrl1, $signedUrl2);
$this->assertTrue(strpos($signedUrl1, 'Expires='.$expiration) !== false);
}
public function tearDown()
{
$this->ossClient->deleteObject($this->bucket, "a.file");
parent::tearDown();
}
public function setUp()
{
parent::setUp();
/**
* 上传本地变量到bucket
*/
$object = "a.file";
$content = file_get_contents(__FILE__);
$options = array(
OssClient::OSS_LENGTH => strlen($content),
OssClient::OSS_HEADERS => array(
'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT',
'Cache-Control' => 'no-cache',
'Content-Disposition' => 'attachment;filename=oss_download.log',
'Content-Encoding' => 'utf-8',
'Content-Language' => 'zh-CN',
'x-oss-server-side-encryption' => 'AES256',
'x-oss-meta-self-define-title' => 'user define meta info',
),
);
try {
$this->ossClient->putObject($this->bucket, $object, $content, $options);
} catch (OssException $e) {
$this->assertFalse(true);
}
}
}

View File

@ -1,216 +1,341 @@
<?php <?php
namespace OSS\Tests; namespace OSS\Tests;
use OSS\Core\OssException; use OSS\Core\OssException;
use OSS\OssClient; use OSS\OssClient;
class OssClientTest extends \PHPUnit_Framework_TestCase class OssClientTest extends TestOssClientBase
{ {
public function testConstrunct() public function testConstrunct()
{ {
try { try {
$ossClient = new OssClient('id', 'key', 'http://oss-cn-hangzhou.aliyuncs.com'); $ossClient = new OssClient('id', 'key', 'http://oss-cn-hangzhou.aliyuncs.com');
$this->assertFalse($ossClient->isUseSSL()); $this->assertFalse($ossClient->isUseSSL());
$ossClient->setUseSSL(true); $ossClient->setUseSSL(true);
$this->assertTrue($ossClient->isUseSSL()); $this->assertTrue($ossClient->isUseSSL());
$this->assertTrue(true); $this->assertTrue(true);
$this->assertEquals(3, $ossClient->getMaxRetries()); $this->assertEquals(3, $ossClient->getMaxRetries());
$ossClient->setMaxTries(4); $ossClient->setMaxTries(4);
$this->assertEquals(4, $ossClient->getMaxRetries()); $this->assertEquals(4, $ossClient->getMaxRetries());
$ossClient->setTimeout(10); $ossClient->setTimeout(10);
$ossClient->setConnectTimeout(20); $ossClient->setConnectTimeout(20);
} catch (OssException $e) { } catch (OssException $e) {
assertFalse(true); assertFalse(true);
} }
} }
public function testConstrunct2() public function testConstrunct2()
{ {
try { try {
$ossClient = new OssClient('id', "", 'http://oss-cn-hangzhou.aliyuncs.com'); $ossClient = new OssClient('id', "", 'http://oss-cn-hangzhou.aliyuncs.com');
$this->assertFalse(true); $this->assertFalse(true);
} catch (OssException $e) { } catch (OssException $e) {
$this->assertEquals("access key secret is empty", $e->getMessage()); $this->assertEquals("access key secret is empty", $e->getMessage());
} }
} }
public function testConstrunct3() public function testConstrunct3()
{ {
try { try {
$ossClient = new OssClient("", 'key', 'http://oss-cn-hangzhou.aliyuncs.com'); $ossClient = new OssClient("", 'key', 'http://oss-cn-hangzhou.aliyuncs.com');
$this->assertFalse(true); $this->assertFalse(true);
} catch (OssException $e) { } catch (OssException $e) {
$this->assertEquals("access key id is empty", $e->getMessage()); $this->assertEquals("access key id is empty", $e->getMessage());
} }
} }
public function testConstrunct4() public function testConstrunct4()
{ {
try { try {
$ossClient = new OssClient('id', 'key', ""); $ossClient = new OssClient('id', 'key', "");
$this->assertFalse(true); $this->assertFalse(true);
} catch (OssException $e) { } catch (OssException $e) {
$this->assertEquals('endpoint is empty', $e->getMessage()); $this->assertEquals('endpoint is empty', $e->getMessage());
} }
} }
public function testConstrunct5() public function testConstrunct5()
{ {
try { try {
$ossClient = new OssClient('id', 'key', "123.123.123.1"); $ossClient = new OssClient('id', 'key', "123.123.123.1");
} catch (OssException $e) { $this->assertTrue(true);
$this->assertTrue(false); } catch (OssException $e) {
} $this->assertTrue(false);
} }
}
public function testConstrunct6()
{ public function testConstrunct6()
try { {
$ossClient = new OssClient('id', 'key', "https://123.123.123.1"); try {
$this->assertTrue($ossClient->isUseSSL()); $ossClient = new OssClient('id', 'key', "https://123.123.123.1");
} catch (OssException $e) { $this->assertTrue($ossClient->isUseSSL());
$this->assertTrue(false); $this->assertTrue(true);
} } catch (OssException $e) {
} $this->assertTrue(false);
}
public function testConstrunct7()
{ try {
try { $ossClient = new OssClient('id', 'key', "https://123.123.123.1:3128");
$ossClient = new OssClient('id', 'key', "http://123.123.123.1"); $this->assertTrue($ossClient->isUseSSL());
$this->assertFalse($ossClient->isUseSSL()); $this->assertTrue(true);
} catch (OssException $e) { } catch (OssException $e) {
$this->assertTrue(false); $this->assertTrue(false);
} }
} }
public function testConstrunct8() public function testConstrunct7()
{ {
try { try {
$ossClient = new OssClient('id', 'key', "http://123.123.123.1", true); $ossClient = new OssClient('id', 'key', "http://123.123.123.1");
$ossClient->listBuckets(); $this->assertFalse($ossClient->isUseSSL());
$this->assertFalse(true); $this->assertTrue(true);
} catch (OssException $e) { } catch (OssException $e) {
$this->assertTrue(false);
} }
}
try {
public function testConstrunct9() $ossClient = new OssClient('id', 'key', "http://123.123.123.1:3128");
{ $this->assertFalse($ossClient->isUseSSL());
try { $this->assertTrue(true);
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; } catch (OssException $e) {
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; $this->assertTrue(false);
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ '; }
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); }
$ossClient->listBuckets();
} catch (OssException $e) { public function testConstrunct8()
$this->assertFalse(true); {
} try {
} $ossClient = new OssClient('id', 'key', "http://123.123.123.1", true);
$ossClient->listBuckets();
public function testSupportPutEmptyObject() $this->assertFalse(true);
{ } catch (OssException $e) {
try {
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; }
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; }
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$bucket = getenv('OSS_BUCKET'); public function testConstrunct9()
$ossClient = new OssClient($accessKeyId, $accessKeySecret , $endpoint, false); {
$ossClient->putObject($bucket,'test_emptybody',''); try {
} catch (OssException $e) { $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$this->assertFalse(true); $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
} $endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
} $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);
$ossClient->listBuckets();
public function testCreateObjectDir() } catch (OssException $e) {
{ $this->assertFalse(true);
try { }
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; }
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ '; public function testConstrunct10()
$bucket = getenv('OSS_BUCKET'); {
$object='test-dir'; try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); $ossClient = new OssClient('id', 'key', "http://ABC-COM.TEST.123.cn", true);
$ossClient->createObjectDir($bucket,$object); $this->assertTrue(true);
} catch (OssException $e) { } catch (OssException $e) {
$this->assertFalse(true); $this->assertTrue(false);
} }
} }
public function testGetBucketCors() public function testConstrunct11()
{ {
try { try {
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; $ossClient = new OssClient('id', 'key', "oss-test.com\\aliyuncs.com");
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; $this->assertFalse(true);
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ '; } catch (OssException $e) {
$bucket = getenv('OSS_BUCKET'); $this->assertEquals('endpoint is invalid:'."oss-test.com\\aliyuncs.com", $e->getMessage());
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); }
$ossClient->getBucketCors($bucket); }
} catch (OssException $e) {
$this->assertFalse(true); public function testConstrunct12()
} {
} try {
$ossClient = new OssClient('id', 'key', "192.168.1.0:abc123");
public function testGetBucketCname() $this->assertFalse(true);
{ } catch (OssException $e) {
try { $this->assertEquals('endpoint is invalid:'."192.168.1.0:abc123", $e->getMessage());
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; }
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; }
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$bucket = getenv('OSS_BUCKET'); public function testSupportPutEmptyObject()
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); {
$ossClient->getBucketCname($bucket); try {
} catch (OssException $e) { $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$this->assertFalse(true); $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
} $endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
} $bucket = $this->bucket;
$ossClient = new OssClient($accessKeyId, $accessKeySecret , $endpoint, false);
public function testProxySupport() $ossClient->putObject($bucket,'test_emptybody','');
{ } catch (OssException $e) {
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; $this->assertFalse(true);
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; }
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$bucket = getenv('OSS_BUCKET') . '-proxy'; //use invalid sts-token, should fail.
$requestProxy = getenv('OSS_PROXY'); try {
$key = 'test-proxy-srv-object'; $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$content = 'test-content'; $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$proxys = parse_url($requestProxy); $endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$bucket = $this->bucket;
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, null, $requestProxy); $ossClient = new OssClient($accessKeyId, $accessKeySecret , $endpoint, false, "invalid-sts-token");
$ossClient->putObject($bucket,'test_emptybody','');
$result = $ossClient->createBucket($bucket); $this->assertTrue(false);
$this->checkProxy($result, $proxys); } catch (OssException $e) {
$this->assertEquals('InvalidAccessKeyId', $e->getErrorCode());
$result = $ossClient->putObject($bucket, $key, $content); }
$this->checkProxy($result, $proxys); }
$result = $ossClient->getObject($bucket, $key);
$this->assertEquals($content, $result); public function testCreateObjectDir()
{
// list object $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$objectListInfo = $ossClient->listObjects($bucket); $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$objectList = $objectListInfo->getObjectList(); $endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$this->assertNotNull($objectList); $bucket = $this->bucket;
$this->assertTrue(is_array($objectList)); $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);
$objects = array();
foreach ($objectList as $value) { try {
$objects[] = $value->getKey(); $object='test-dir';
} $ossClient->createObjectDir($bucket,$object);
$this->assertEquals(1, count($objects)); } catch (OssException $e) {
$this->assertTrue(in_array($key, $objects)); $this->assertFalse(true);
}
$result = $ossClient->deleteObject($bucket, $key);
$this->checkProxy($result,$proxys); try {
$object='0';
$result = $ossClient->deleteBucket($bucket); $ossClient->createObjectDir($bucket,$object);
$this->checkProxy($result, $proxys); $ossClient->putObject($bucket,$object, '');
} } catch (OssException $e) {
var_dump($e);
private function checkProxy($result, $proxys) $this->assertFalse(true);
{ }
$this->assertEquals($result['info']['primary_ip'], $proxys['host']); }
$this->assertEquals($result['info']['primary_port'], $proxys['port']);
$this->assertTrue(array_key_exists('via', $result)); public function testGetBucketCors()
} {
try {
} $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$bucket = getenv('OSS_BUCKET');
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);
$ossClient->getBucketCors($bucket);
} catch (OssException $e) {
$this->assertFalse(true);
}
}
public function testGetBucketCname()
{
try {
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$bucket = $this->bucket;
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);
$ossClient->getBucketCname($bucket);
} catch (OssException $e) {
$this->assertFalse(true);
}
}
public function testProxySupport()
{
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$bucket = getenv('OSS_BUCKET') . '-proxy';
$requestProxy = getenv('OSS_PROXY');
$key = 'test-proxy-srv-object';
$content = 'test-content';
$proxys = parse_url($requestProxy);
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, null, $requestProxy);
$result = $ossClient->createBucket($bucket);
$this->checkProxy($result, $proxys);
$result = $ossClient->putObject($bucket, $key, $content);
$this->checkProxy($result, $proxys);
$result = $ossClient->getObject($bucket, $key);
$this->assertEquals($content, $result);
// list object
$objectListInfo = $ossClient->listObjects($bucket);
$objectList = $objectListInfo->getObjectList();
$this->assertNotNull($objectList);
$this->assertTrue(is_array($objectList));
$objects = array();
foreach ($objectList as $value) {
$objects[] = $value->getKey();
}
$this->assertEquals(1, count($objects));
$this->assertTrue(in_array($key, $objects));
$result = $ossClient->deleteObject($bucket, $key);
$this->checkProxy($result,$proxys);
$result = $ossClient->deleteBucket($bucket);
$this->checkProxy($result, $proxys);
}
private function checkProxy($result, $proxys)
{
$this->assertEquals($result['info']['primary_ip'], $proxys['host']);
$this->assertEquals($result['info']['primary_port'], $proxys['port']);
$this->assertTrue(array_key_exists('via', $result));
}
public function testIpEndpoint()
{
try {
$accessKeyId = 'sk' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = '192.168.1.1';
$bucket = getenv('OSS_BUCKET');
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);
$object = "a.file";
$timeout = 3600;
$options = array('Content-Type' => 'txt');
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options);
$this->assertTrue(strpos($signedUrl, '192.168.1.1/skyranch-php-test/a.file?') != false);
} catch (OssException $e) {
$this->assertFalse(true);
}
}
public function testCnameEndpoint()
{
try {
$accessKeyId = 'sk' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = 'cname.endpoint';
$bucket = getenv('OSS_BUCKET');
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, true);
$object = "a.file";
$timeout = 3600;
$options = array('Content-Type' => 'txt');
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options);
$this->assertTrue(strpos($signedUrl, 'cname.endpoint/a.file?') != false);
} catch (OssException $e) {
$this->assertFalse(true);
}
}
public function testStsToken()
{
try {
$accessKeyId = 'sk' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$bucket = getenv('OSS_BUCKET');
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, "test-token");
$object = "a.file";
$timeout = 3600;
$options = array('Content-Type' => 'txt');
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options);
$this->assertTrue(strpos($signedUrl, 'security-token=test-token') != false);
} catch (OssException $e) {
$this->assertFalse(true);
}
}
}

View File

@ -0,0 +1,96 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
use OSS\Http\RequestCore;
use OSS\Http\ResponseCore;
use OSS\OssClient;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssTrafficLimitTest extends TestOssClientBase
{
function testTrafficLimitInHeader()
{
$options = array(
OssClient::OSS_HEADERS => array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
));
try {
$result = $this->ossClient->putObject($this->bucket, 'default-object', 'content', $options);
$this->assertTrue(true);
$this->assertTrue(isset($result["x-oss-qos-delay-time"]));
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$result = $this->ossClient->appendObject($this->bucket, 'append-object', 'content', 0, $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$result = $this->ossClient->copyObject($this->bucket, 'default-object', $this->bucket, 'copy-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
try {
$result = $this->ossClient->getObject($this->bucket, 'default-object', $options);
$this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
}
function testTrafficLimitInQuery()
{
$options = array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
);
$object = "get.file";
$content = 'hello world';
$this->ossClient->putObject($this->bucket, $object, $content);
$timeout = 3600;
try {
$signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "GET", $options);
$this->assertTrue(stripos($signedUrl, 'x-oss-traffic-limit=819200') > 0);
} catch (OssException $e) {
$this->assertFalse(true);
}
$request = new RequestCore($signedUrl);
$request->set_method('GET');
$request->add_header('Content-Type', '');
$request->send_request();
$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());
$this->assertEquals($content, $res->body);
$object = "put.file";
$timeout = 3600;
try {
$signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options);
$this->assertTrue(stripos($signedUrl, 'x-oss-traffic-limit=819200') > 0);
$request = new RequestCore($signedUrl);
$request->set_method('PUT');
$request->add_header('Content-Type', '');
$request->add_header('Content-Length', strlen($content));
$request->set_body($content);
$request->send_request();
$res = new ResponseCore($request->get_response_header(),
$request->get_response_body(), $request->get_response_code());
$this->assertTrue($res->isOK());
} catch (OssException $e) {
$this->assertFalse(true);
}
}
}

View File

@ -155,6 +155,10 @@ BBBB;
public function testGetMd5SumForFile() public function testGetMd5SumForFile()
{ {
$this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, filesize(__FILE__) - 1), base64_encode(md5(file_get_contents(__FILE__), true))); $this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, filesize(__FILE__) - 1), base64_encode(md5(file_get_contents(__FILE__), true)));
// false case
$this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, OssClient::OSS_MAX_PART_SIZE + 1), "");
$this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, filesize(__FILE__) + 1), "");
} }
public function testGenerateFile() public function testGenerateFile()
@ -242,10 +246,55 @@ BBBB;
$str = OssUtil::getHostPortFromEndpoint('192.168.1.10:8080'); $str = OssUtil::getHostPortFromEndpoint('192.168.1.10:8080');
$this->assertEquals('192.168.1.10:8080', $str); $this->assertEquals('192.168.1.10:8080', $str);
$str = OssUtil::getHostPortFromEndpoint('http:///path?arg=value#anchor');
$this->assertEquals('', $str);
$str = OssUtil::getHostPortFromEndpoint('file://username:password@hostname:80/path?arg=value#anchor'); $str = OssUtil::getHostPortFromEndpoint('file://username:password@hostname:80/path?arg=value#anchor');
$this->assertEquals('hostname:80', $str); $this->assertEquals('hostname:80', $str);
$str = OssUtil::getHostPortFromEndpoint('https://WWW.hostname.com-_www.test.com');
$this->assertEquals('WWW.hostname.com-_www.test.com', $str);
try {
$str = OssUtil::getHostPortFromEndpoint('http:///path?arg=value#anchor');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
try {
$str = OssUtil::getHostPortFromEndpoint('https://www.hostname.com\www.test.com');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
try {
$str = OssUtil::getHostPortFromEndpoint('www.hostname.com-_*www.test.com');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
try {
$str = OssUtil::getHostPortFromEndpoint('www.hostname.com:ab123');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
try {
$str = OssUtil::getHostPortFromEndpoint('www.hostname.com:');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
}
public function testDecodeKey()
{
try {
OssUtil::decodeKey("key", "unknown");
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
}
} }
} }

View File

@ -0,0 +1,58 @@
<?php
namespace OSS\Tests;
use OSS\Core\OssException;
use OSS\Model\StorageCapacityConfig;
class StorageCapacityConfigTest extends \PHPUnit_Framework_TestCase
{
private $validXml_10 = <<<BBBB
<?xml version="1.0" encoding="utf-8"?>
<BucketUserQos>
<StorageCapacity>10</StorageCapacity>
</BucketUserQos>
BBBB;
private $validXml_20 = <<<BBBB
<?xml version="1.0" encoding="utf-8"?>
<BucketUserQos>
<StorageCapacity>20</StorageCapacity>
</BucketUserQos>
BBBB;
public function testConstruct()
{
$config = new StorageCapacityConfig(10);
$this->assertEquals($config->getStorageCapacity(), 10);
$this->assertEquals($this->cleanXml($this->validXml_10), $this->cleanXml($config->serializeToXml()));
}
public function testSetStorageCapacity()
{
$config = new StorageCapacityConfig(2);
$config->setStorageCapacity(20);
$this->assertEquals($this->cleanXml($this->validXml_20), $this->cleanXml($config->serializeToXml()));
$this->assertEquals($this->cleanXml($this->validXml_20), $this->cleanXml($config->__toString()));
}
public function testParseFromXml()
{
try {
$config = new StorageCapacityConfig(10);
$config->parseFromXml('invaide xml');
$this->assertTrue(false);
} catch (OssException $e) {
$this->assertTrue(true);
if (strpos($e, "Not implemented.") == false)
{
$this->assertTrue(false);
}
}
}
private function cleanXml($xml)
{
return str_replace("\n", "", str_replace("\r", "", $xml));
}
}

View File

@ -13,7 +13,7 @@ class SymlinkTest extends TestOssClientBase
{ {
public function testPutSymlink() public function testPutSymlink()
{ {
$bucket = getenv('OSS_BUCKET'); $bucket = $this->bucket;
$symlink = 'test-link'; $symlink = 'test-link';
$special_object = 'exist_object^$#!~'; $special_object = 'exist_object^$#!~';
$object = 'exist_object'; $object = 'exist_object';
@ -31,10 +31,13 @@ class SymlinkTest extends TestOssClientBase
public function testGetSymlink() public function testGetSymlink()
{ {
$bucket = getenv('OSS_BUCKET'); $bucket = $this->bucket;
$symlink = 'test-link'; $symlink = 'test-link';
$object = 'exist_object^$#!~'; $object = 'exist_object^$#!~';
$this->ossClient ->putObject($bucket, $object, 'test_content');
$this->ossClient->putSymlink($bucket, $symlink, $object);
$result = $this->ossClient->getSymlink($bucket, $symlink); $result = $this->ossClient->getSymlink($bucket, $symlink);
$this->assertEquals($result[OssClient::OSS_SYMLINK_TARGET], $object); $this->assertEquals($result[OssClient::OSS_SYMLINK_TARGET], $object);
$this->assertEquals('200', $result[OssClient::OSS_INFO][OssClient::OSS_HTTP_CODE]); $this->assertEquals('200', $result[OssClient::OSS_INFO][OssClient::OSS_HTTP_CODE]);
@ -44,7 +47,7 @@ class SymlinkTest extends TestOssClientBase
public function testPutNullSymlink() public function testPutNullSymlink()
{ {
$bucket = getenv('OSS_BUCKET'); $bucket = $this->bucket;
$symlink = 'null-link'; $symlink = 'null-link';
$object_not_exist = 'not_exist_object+$#!b不'; $object_not_exist = 'not_exist_object+$#!b不';
$this->ossClient->putSymlink($bucket, $symlink, $object_not_exist); $this->ossClient->putSymlink($bucket, $symlink, $object_not_exist);
@ -53,13 +56,13 @@ class SymlinkTest extends TestOssClientBase
$this->ossClient->getObject($bucket, $symlink); $this->ossClient->getObject($bucket, $symlink);
$this->assertTrue(false); $this->assertTrue(false);
}catch (OssException $e){ }catch (OssException $e){
$this->assertEquals('The specified key does not exist.', $e->getErrorMessage()); $this->assertEquals('The symlink target object does not exist', $e->getErrorMessage());
} }
} }
public function testGetNullSymlink() public function testGetNullSymlink()
{ {
$bucket = getenv('OSS_BUCKET'); $bucket = $this->bucket;
$symlink = 'null-link-new'; $symlink = 'null-link-new';
try{ try{

View File

@ -20,10 +20,10 @@ class TestOssClientBase extends \PHPUnit_Framework_TestCase
public function setUp() public function setUp()
{ {
$this->bucket = Common::getBucketName() . rand(100000, 999999); $this->bucket = Common::getBucketName() .'-'. time();
$this->ossClient = Common::getOssClient(); $this->ossClient = Common::getOssClient();
$this->ossClient->createBucket($this->bucket); $this->ossClient->createBucket($this->bucket);
Common::waitMetaSync(); Common::waitMetaSync();
} }
public function tearDown() public function tearDown()

View File

@ -37,8 +37,8 @@ namespace Composer\Autoload;
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/ * @see https://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/ * @see https://www.php-fig.org/psr/psr-4/
*/ */
class ClassLoader class ClassLoader
{ {
@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes() public function getPrefixes()
{ {
if (!empty($this->prefixesPsr0)) { if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0); return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
} }
return array(); return array();

View File

@ -0,0 +1,218 @@
<?php
namespace Composer;
use Composer\Semver\VersionParser;
class InstalledVersions
{
private static $installed = array (
'root' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'e91742b194ff46741075d52a4ea0fc1148659407',
'name' => '__root__',
),
'versions' =>
array (
'__root__' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'e91742b194ff46741075d52a4ea0fc1148659407',
),
'aliyuncs/oss-sdk-php' =>
array (
'pretty_version' => 'v2.4.1',
'version' => '2.4.1.0',
'aliases' =>
array (
),
'reference' => '492866331b7bafaac09506cf42f351b7e9e63766',
),
),
);
public static function getInstalledPackages()
{
return array_keys(self::$installed['versions']);
}
public static function isInstalled($packageName)
{
return isset(self::$installed['versions'][$packageName]);
}
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
public static function getVersionRanges($packageName)
{
if (!isset(self::$installed['versions'][$packageName])) {
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
$ranges = array();
if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
public static function getVersion($packageName)
{
if (!isset(self::$installed['versions'][$packageName])) {
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
if (!isset(self::$installed['versions'][$packageName]['version'])) {
return null;
}
return self::$installed['versions'][$packageName]['version'];
}
public static function getPrettyVersion($packageName)
{
if (!isset(self::$installed['versions'][$packageName])) {
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return self::$installed['versions'][$packageName]['pretty_version'];
}
public static function getReference($packageName)
{
if (!isset(self::$installed['versions'][$packageName])) {
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
if (!isset(self::$installed['versions'][$packageName]['reference'])) {
return null;
}
return self::$installed['versions'][$packageName]['reference'];
}
public static function getRootPackage()
{
return self::$installed['root'];
}
public static function getRawData()
{
return self::$installed;
}
public static function reload($data)
{
self::$installed = $data;
}
}

View File

@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'OSS\\Core\\MimeTypes' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php', 'OSS\\Core\\MimeTypes' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php',
'OSS\\Core\\OssException' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php', 'OSS\\Core\\OssException' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php',
'OSS\\Core\\OssUtil' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php', 'OSS\\Core\\OssUtil' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php',
@ -14,12 +15,18 @@ return array(
'OSS\\Http\\ResponseCore' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php', 'OSS\\Http\\ResponseCore' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php',
'OSS\\Model\\BucketInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php', 'OSS\\Model\\BucketInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php',
'OSS\\Model\\BucketListInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php', 'OSS\\Model\\BucketListInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php',
'OSS\\Model\\BucketStat' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketStat.php',
'OSS\\Model\\CnameConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php', 'OSS\\Model\\CnameConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php',
'OSS\\Model\\CorsConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php', 'OSS\\Model\\CorsConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php',
'OSS\\Model\\CorsRule' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php', 'OSS\\Model\\CorsRule' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php',
'OSS\\Model\\DeleteMarkerInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteMarkerInfo.php',
'OSS\\Model\\DeleteObjectInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteObjectInfo.php',
'OSS\\Model\\DeletedObjectInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/DeletedObjectInfo.php',
'OSS\\Model\\ExtendWormConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ExtendWormConfig.php',
'OSS\\Model\\GetLiveChannelHistory' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php', 'OSS\\Model\\GetLiveChannelHistory' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php',
'OSS\\Model\\GetLiveChannelInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php', 'OSS\\Model\\GetLiveChannelInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php',
'OSS\\Model\\GetLiveChannelStatus' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php', 'OSS\\Model\\GetLiveChannelStatus' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php',
'OSS\\Model\\InitiateWormConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/InitiateWormConfig.php',
'OSS\\Model\\LifecycleAction' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php', 'OSS\\Model\\LifecycleAction' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php',
'OSS\\Model\\LifecycleConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php', 'OSS\\Model\\LifecycleConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php',
'OSS\\Model\\LifecycleRule' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php', 'OSS\\Model\\LifecycleRule' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php',
@ -32,12 +39,21 @@ return array(
'OSS\\Model\\LoggingConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php', 'OSS\\Model\\LoggingConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php',
'OSS\\Model\\ObjectInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php', 'OSS\\Model\\ObjectInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php',
'OSS\\Model\\ObjectListInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php', 'OSS\\Model\\ObjectListInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php',
'OSS\\Model\\ObjectVersionInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionInfo.php',
'OSS\\Model\\ObjectVersionListInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionListInfo.php',
'OSS\\Model\\PartInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php', 'OSS\\Model\\PartInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php',
'OSS\\Model\\PrefixInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php', 'OSS\\Model\\PrefixInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php',
'OSS\\Model\\RefererConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php', 'OSS\\Model\\RefererConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php',
'OSS\\Model\\RequestPaymentConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/RequestPaymentConfig.php',
'OSS\\Model\\RestoreConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/RestoreConfig.php',
'OSS\\Model\\ServerSideEncryptionConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ServerSideEncryptionConfig.php',
'OSS\\Model\\StorageCapacityConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php', 'OSS\\Model\\StorageCapacityConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php',
'OSS\\Model\\Tag' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/Tag.php',
'OSS\\Model\\TaggingConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/TaggingConfig.php',
'OSS\\Model\\UploadInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php', 'OSS\\Model\\UploadInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php',
'OSS\\Model\\VersioningConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/VersioningConfig.php',
'OSS\\Model\\WebsiteConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php', 'OSS\\Model\\WebsiteConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php',
'OSS\\Model\\WormConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/WormConfig.php',
'OSS\\Model\\XmlConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php', 'OSS\\Model\\XmlConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php',
'OSS\\OssClient' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/OssClient.php', 'OSS\\OssClient' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/OssClient.php',
'OSS\\Result\\AclResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php', 'OSS\\Result\\AclResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php',
@ -45,8 +61,16 @@ return array(
'OSS\\Result\\BodyResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php', 'OSS\\Result\\BodyResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php',
'OSS\\Result\\CallbackResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php', 'OSS\\Result\\CallbackResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php',
'OSS\\Result\\CopyObjectResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php', 'OSS\\Result\\CopyObjectResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php',
'OSS\\Result\\DeleteObjectVersionsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectVersionsResult.php',
'OSS\\Result\\DeleteObjectsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php', 'OSS\\Result\\DeleteObjectsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php',
'OSS\\Result\\ExistResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php', 'OSS\\Result\\ExistResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php',
'OSS\\Result\\GetBucketEncryptionResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketEncryptionResult.php',
'OSS\\Result\\GetBucketInfoResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketInfoResult.php',
'OSS\\Result\\GetBucketRequestPaymentResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketRequestPaymentResult.php',
'OSS\\Result\\GetBucketStatResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketStatResult.php',
'OSS\\Result\\GetBucketTagsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTagsResult.php',
'OSS\\Result\\GetBucketVersioningResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketVersioningResult.php',
'OSS\\Result\\GetBucketWormResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketWormResult.php',
'OSS\\Result\\GetCnameResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php', 'OSS\\Result\\GetCnameResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php',
'OSS\\Result\\GetCorsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php', 'OSS\\Result\\GetCorsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php',
'OSS\\Result\\GetLifecycleResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php', 'OSS\\Result\\GetLifecycleResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php',
@ -59,10 +83,12 @@ return array(
'OSS\\Result\\GetStorageCapacityResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php', 'OSS\\Result\\GetStorageCapacityResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php',
'OSS\\Result\\GetWebsiteResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php', 'OSS\\Result\\GetWebsiteResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php',
'OSS\\Result\\HeaderResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php', 'OSS\\Result\\HeaderResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php',
'OSS\\Result\\InitiateBucketWormResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateBucketWormResult.php',
'OSS\\Result\\InitiateMultipartUploadResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php', 'OSS\\Result\\InitiateMultipartUploadResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php',
'OSS\\Result\\ListBucketsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php', 'OSS\\Result\\ListBucketsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php',
'OSS\\Result\\ListLiveChannelResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php', 'OSS\\Result\\ListLiveChannelResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php',
'OSS\\Result\\ListMultipartUploadResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php', 'OSS\\Result\\ListMultipartUploadResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php',
'OSS\\Result\\ListObjectVersionsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectVersionsResult.php',
'OSS\\Result\\ListObjectsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php', 'OSS\\Result\\ListObjectsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php',
'OSS\\Result\\ListPartsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php', 'OSS\\Result\\ListPartsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php',
'OSS\\Result\\PutLiveChannelResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php', 'OSS\\Result\\PutLiveChannelResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php',

View File

@ -22,13 +22,15 @@ class ComposerAutoloaderInitc01f83c61c7df694fdf929c88fea6382
return self::$loader; return self::$loader;
} }
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInitc01f83c61c7df694fdf929c88fea6382', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInitc01f83c61c7df694fdf929c88fea6382', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitc01f83c61c7df694fdf929c88fea6382', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInitc01f83c61c7df694fdf929c88fea6382', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php'; require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitc01f83c61c7df694fdf929c88fea6382::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInitc01f83c61c7df694fdf929c88fea6382::getInitializer($loader));
} else { } else {

View File

@ -21,6 +21,7 @@ class ComposerStaticInitc01f83c61c7df694fdf929c88fea6382
); );
public static $classMap = array ( public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'OSS\\Core\\MimeTypes' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php', 'OSS\\Core\\MimeTypes' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php',
'OSS\\Core\\OssException' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php', 'OSS\\Core\\OssException' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php',
'OSS\\Core\\OssUtil' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php', 'OSS\\Core\\OssUtil' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php',
@ -29,12 +30,18 @@ class ComposerStaticInitc01f83c61c7df694fdf929c88fea6382
'OSS\\Http\\ResponseCore' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php', 'OSS\\Http\\ResponseCore' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php',
'OSS\\Model\\BucketInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php', 'OSS\\Model\\BucketInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php',
'OSS\\Model\\BucketListInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php', 'OSS\\Model\\BucketListInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php',
'OSS\\Model\\BucketStat' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketStat.php',
'OSS\\Model\\CnameConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php', 'OSS\\Model\\CnameConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php',
'OSS\\Model\\CorsConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php', 'OSS\\Model\\CorsConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php',
'OSS\\Model\\CorsRule' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php', 'OSS\\Model\\CorsRule' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php',
'OSS\\Model\\DeleteMarkerInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteMarkerInfo.php',
'OSS\\Model\\DeleteObjectInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteObjectInfo.php',
'OSS\\Model\\DeletedObjectInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/DeletedObjectInfo.php',
'OSS\\Model\\ExtendWormConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ExtendWormConfig.php',
'OSS\\Model\\GetLiveChannelHistory' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php', 'OSS\\Model\\GetLiveChannelHistory' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php',
'OSS\\Model\\GetLiveChannelInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php', 'OSS\\Model\\GetLiveChannelInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php',
'OSS\\Model\\GetLiveChannelStatus' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php', 'OSS\\Model\\GetLiveChannelStatus' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php',
'OSS\\Model\\InitiateWormConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/InitiateWormConfig.php',
'OSS\\Model\\LifecycleAction' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php', 'OSS\\Model\\LifecycleAction' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php',
'OSS\\Model\\LifecycleConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php', 'OSS\\Model\\LifecycleConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php',
'OSS\\Model\\LifecycleRule' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php', 'OSS\\Model\\LifecycleRule' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php',
@ -47,12 +54,21 @@ class ComposerStaticInitc01f83c61c7df694fdf929c88fea6382
'OSS\\Model\\LoggingConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php', 'OSS\\Model\\LoggingConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php',
'OSS\\Model\\ObjectInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php', 'OSS\\Model\\ObjectInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php',
'OSS\\Model\\ObjectListInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php', 'OSS\\Model\\ObjectListInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php',
'OSS\\Model\\ObjectVersionInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionInfo.php',
'OSS\\Model\\ObjectVersionListInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionListInfo.php',
'OSS\\Model\\PartInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php', 'OSS\\Model\\PartInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php',
'OSS\\Model\\PrefixInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php', 'OSS\\Model\\PrefixInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php',
'OSS\\Model\\RefererConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php', 'OSS\\Model\\RefererConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php',
'OSS\\Model\\RequestPaymentConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/RequestPaymentConfig.php',
'OSS\\Model\\RestoreConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/RestoreConfig.php',
'OSS\\Model\\ServerSideEncryptionConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ServerSideEncryptionConfig.php',
'OSS\\Model\\StorageCapacityConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php', 'OSS\\Model\\StorageCapacityConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php',
'OSS\\Model\\Tag' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/Tag.php',
'OSS\\Model\\TaggingConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/TaggingConfig.php',
'OSS\\Model\\UploadInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php', 'OSS\\Model\\UploadInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php',
'OSS\\Model\\VersioningConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/VersioningConfig.php',
'OSS\\Model\\WebsiteConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php', 'OSS\\Model\\WebsiteConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php',
'OSS\\Model\\WormConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/WormConfig.php',
'OSS\\Model\\XmlConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php', 'OSS\\Model\\XmlConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php',
'OSS\\OssClient' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/OssClient.php', 'OSS\\OssClient' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/OssClient.php',
'OSS\\Result\\AclResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php', 'OSS\\Result\\AclResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php',
@ -60,8 +76,16 @@ class ComposerStaticInitc01f83c61c7df694fdf929c88fea6382
'OSS\\Result\\BodyResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php', 'OSS\\Result\\BodyResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php',
'OSS\\Result\\CallbackResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php', 'OSS\\Result\\CallbackResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php',
'OSS\\Result\\CopyObjectResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php', 'OSS\\Result\\CopyObjectResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php',
'OSS\\Result\\DeleteObjectVersionsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectVersionsResult.php',
'OSS\\Result\\DeleteObjectsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php', 'OSS\\Result\\DeleteObjectsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php',
'OSS\\Result\\ExistResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php', 'OSS\\Result\\ExistResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php',
'OSS\\Result\\GetBucketEncryptionResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketEncryptionResult.php',
'OSS\\Result\\GetBucketInfoResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketInfoResult.php',
'OSS\\Result\\GetBucketRequestPaymentResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketRequestPaymentResult.php',
'OSS\\Result\\GetBucketStatResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketStatResult.php',
'OSS\\Result\\GetBucketTagsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTagsResult.php',
'OSS\\Result\\GetBucketVersioningResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketVersioningResult.php',
'OSS\\Result\\GetBucketWormResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketWormResult.php',
'OSS\\Result\\GetCnameResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php', 'OSS\\Result\\GetCnameResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php',
'OSS\\Result\\GetCorsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php', 'OSS\\Result\\GetCorsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php',
'OSS\\Result\\GetLifecycleResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php', 'OSS\\Result\\GetLifecycleResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php',
@ -74,10 +98,12 @@ class ComposerStaticInitc01f83c61c7df694fdf929c88fea6382
'OSS\\Result\\GetStorageCapacityResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php', 'OSS\\Result\\GetStorageCapacityResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php',
'OSS\\Result\\GetWebsiteResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php', 'OSS\\Result\\GetWebsiteResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php',
'OSS\\Result\\HeaderResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php', 'OSS\\Result\\HeaderResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php',
'OSS\\Result\\InitiateBucketWormResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateBucketWormResult.php',
'OSS\\Result\\InitiateMultipartUploadResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php', 'OSS\\Result\\InitiateMultipartUploadResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php',
'OSS\\Result\\ListBucketsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php', 'OSS\\Result\\ListBucketsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php',
'OSS\\Result\\ListLiveChannelResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php', 'OSS\\Result\\ListLiveChannelResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php',
'OSS\\Result\\ListMultipartUploadResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php', 'OSS\\Result\\ListMultipartUploadResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php',
'OSS\\Result\\ListObjectVersionsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectVersionsResult.php',
'OSS\\Result\\ListObjectsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php', 'OSS\\Result\\ListObjectsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php',
'OSS\\Result\\ListPartsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php', 'OSS\\Result\\ListPartsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php',
'OSS\\Result\\PutLiveChannelResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php', 'OSS\\Result\\PutLiveChannelResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php',

View File

@ -1,51 +1,60 @@
[ {
{ "packages": [
"name": "aliyuncs/oss-sdk-php", {
"version": "v2.3.1", "name": "aliyuncs/oss-sdk-php",
"version_normalized": "2.3.1.0", "version": "v2.4.1",
"source": { "version_normalized": "2.4.1.0",
"type": "git", "source": {
"url": "https://github.com/aliyun/aliyun-oss-php-sdk.git", "type": "git",
"reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a" "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
}, "reference": "492866331b7bafaac09506cf42f351b7e9e63766"
"dist": { },
"type": "zip", "dist": {
"url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/053d7ba9e798e4c09b9c5c1edab153d25ea9643a", "type": "zip",
"reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a", "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/492866331b7bafaac09506cf42f351b7e9e63766",
"shasum": "", "reference": "492866331b7bafaac09506cf42f351b7e9e63766",
"mirrors": [ "shasum": "",
{ "mirrors": [
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", {
"preferred": true "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~1.0"
},
"time": "2020-09-29T06:23:57+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"OSS\\": "src/OSS"
} }
] },
}, "notification-url": "https://packagist.org/downloads/",
"require": { "license": [
"php": ">=5.3" "MIT"
}, ],
"require-dev": { "authors": [
"phpunit/phpunit": "~4.0", {
"satooshi/php-coveralls": "~1.0" "name": "Aliyuncs",
}, "homepage": "http://www.aliyun.com"
"time": "2019-11-15T11:05:42+00:00", }
"type": "library", ],
"installation-source": "dist", "description": "Aliyun OSS SDK for PHP",
"autoload": { "homepage": "http://www.aliyun.com/product/oss/",
"psr-4": { "support": {
"OSS\\": "src/OSS" "issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues",
} "source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.4.1"
}, },
"notification-url": "https://packagist.org/downloads/", "install-path": "../aliyuncs/oss-sdk-php"
"license": [ }
"MIT" ],
], "dev": true,
"authors": [ "dev-package-names": []
{ }
"name": "Aliyuncs",
"homepage": "http://www.aliyun.com"
}
],
"description": "Aliyun OSS SDK for PHP",
"homepage": "http://www.aliyun.com/product/oss/"
}
]

33
sdk/vendor/composer/installed.php vendored Normal file
View File

@ -0,0 +1,33 @@
<?php return array (
'root' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'e91742b194ff46741075d52a4ea0fc1148659407',
'name' => '__root__',
),
'versions' =>
array (
'__root__' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'e91742b194ff46741075d52a4ea0fc1148659407',
),
'aliyuncs/oss-sdk-php' =>
array (
'pretty_version' => 'v2.4.1',
'version' => '2.4.1.0',
'aliases' =>
array (
),
'reference' => '492866331b7bafaac09506cf42f351b7e9e63766',
),
),
);

26
sdk/vendor/composer/platform_check.php vendored Normal file
View File

@ -0,0 +1,26 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 50300)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 5.3.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}