diff --git a/Plugin.php b/Plugin.php
index 0d4d092..8efe068 100644
--- a/Plugin.php
+++ b/Plugin.php
@@ -1,6 +1,6 @@
location = $location;
- $this->name = $name;
- $this->createDate = $createDate;
- }
-
- /**
- * Get bucket location
- *
- * @return string
- */
- public function getLocation()
- {
- return $this->location;
- }
-
- /**
- * Get bucket name
- *
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Get bucket creation time.
- *
- * @return string
- */
- public function getCreateDate()
- {
- return $this->createDate;
- }
-
- /**
- * bucket region
- *
- * @var string
- */
- private $location;
- /**
- * bucket name
- *
- * @var string
- */
- private $name;
-
- /**
- * bucket creation time
- *
- * @var string
- */
- private $createDate;
-
-}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ListBucketsResultTest.php b/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ListBucketsResultTest.php
deleted file mode 100644
index 1abe1f5..0000000
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ListBucketsResultTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
- ut_test_put_bucket
- ut_test_put_bucket
-
-
-
- oss-cn-hangzhou-a
- xz02tphky6fjfiuc0
- 2014-05-15T11:18:32.000Z
-
-
- oss-cn-hangzhou-a
- xz02tphky6fjfiuc1
- 2014-05-15T11:18:32.000Z
-
-
-
-BBBB;
-
- private $nullXml = <<
-
-
- ut_test_put_bucket
- ut_test_put_bucket
-
-
-
-
-BBBB;
-
- public function testParseValidXml()
- {
- $response = new ResponseCore(array(), $this->validXml, 200);
- $result = new ListBucketsResult($response);
- $this->assertTrue($result->isOK());
- $this->assertNotNull($result->getData());
- $this->assertNotNull($result->getRawResponse());
- $bucketListInfo = $result->getData();
- $this->assertEquals(2, count($bucketListInfo->getBucketList()));
- }
-
- public function testParseNullXml()
- {
- $response = new ResponseCore(array(), $this->nullXml, 200);
- $result = new ListBucketsResult($response);
- $this->assertTrue($result->isOK());
- $this->assertNotNull($result->getData());
- $this->assertNotNull($result->getRawResponse());
- $bucketListInfo = $result->getData();
- $this->assertEquals(0, count($bucketListInfo->getBucketList()));
- }
-
- public function test403()
- {
- $errorHeader = array(
- 'x-oss-request-id' => '1a2b-3c4d'
- );
-
- $errorBody = <<< BBBB
-
-
- NoSuchBucket
- The specified bucket does not exist.
- 566B870D207FB3044302EB0A
- hello.oss-test.aliyun-inc.com
- hello
-
-BBBB;
- $response = new ResponseCore($errorHeader, $errorBody, 403);
- try {
- new ListBucketsResult($response);
- } catch (OssException $e) {
- $this->assertEquals(
- $e->getMessage(),
- 'NoSuchBucket: The specified bucket does not exist. RequestId: 1a2b-3c4d');
- $this->assertEquals($e->getHTTPStatus(), '403');
- $this->assertEquals($e->getRequestId(), '1a2b-3c4d');
- $this->assertEquals($e->getErrorCode(), 'NoSuchBucket');
- $this->assertEquals($e->getErrorMessage(), 'The specified bucket does not exist.');
- $this->assertEquals($e->getDetails(), $errorBody);
- }
- }
-}
diff --git a/aliyun-oss-php-sdk-2.3.1/.coveralls.yml b/aliyun-oss-php-sdk-2.4.3/.coveralls.yml
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/.coveralls.yml
rename to aliyun-oss-php-sdk-2.4.3/.coveralls.yml
diff --git a/aliyun-oss-php-sdk-2.3.1/.gitignore b/aliyun-oss-php-sdk-2.4.3/.gitignore
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/.gitignore
rename to aliyun-oss-php-sdk-2.4.3/.gitignore
diff --git a/aliyun-oss-php-sdk-2.3.1/.travis.yml b/aliyun-oss-php-sdk-2.4.3/.travis.yml
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/.travis.yml
rename to aliyun-oss-php-sdk-2.4.3/.travis.yml
diff --git a/aliyun-oss-php-sdk-2.3.1/CHANGELOG.md b/aliyun-oss-php-sdk-2.4.3/CHANGELOG.md
old mode 100644
new mode 100755
similarity index 71%
rename from aliyun-oss-php-sdk-2.3.1/CHANGELOG.md
rename to aliyun-oss-php-sdk-2.4.3/CHANGELOG.md
index d349d90..cd983e7
--- a/aliyun-oss-php-sdk-2.3.1/CHANGELOG.md
+++ b/aliyun-oss-php-sdk-2.4.3/CHANGELOG.md
@@ -1,6 +1,41 @@
# ChangeLog - Aliyun OSS SDK for PHP
-## v2.3.1 / 2019-011-15
+## v2.4.3 / 2021-08-25
+* Fixed: integer overflow in PHP5.x.
+
+## v2.4.2 / 2021-06-04
+* Compatible with PHP8.
+* Fixed: compatible with PHP5.4.
+* Fixed: the signature is incorrect in some scenarios
+* Update: change $requestUrl from a member variable to a local variable.
+
+## v2.4.1 / 2020-09-29
+* Fixed: the getBucketPolicy bug.
+
+
+## v2.4.0 / 2020-08-31
+
+* Added: disable Expect: 100-continue
+* Added: support getBucketInfo
+* Added: support getBucketStat
+* Added: support bucket policy
+* Added: support bucket encryption
+* Added: support bucket tagging
+* Added: support bucket worm
+* Added: support versioning
+* Added: support request payment
+* Added: support object tagging
+* Added: support code archive
+* Added: support process object
+* Added: support traffic limit paramter
+* Added: support upload object from file handle
+* Added: support getSimplifiedObjectMeta
+* Fixed: the object name can not be '0' stirng.
+* Update: endpoint validity check
+* Update: add new pre-signed url api
+
+
+## v2.3.1 / 2019-01-15
* translate chinese comments into english
* Added: endpoint validity check
diff --git a/aliyun-oss-php-sdk-2.3.1/LICENSE.md b/aliyun-oss-php-sdk-2.4.3/LICENSE.md
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/LICENSE.md
rename to aliyun-oss-php-sdk-2.4.3/LICENSE.md
diff --git a/aliyun-oss-php-sdk-2.3.1/README-CN.md b/aliyun-oss-php-sdk-2.4.3/README-CN.md
old mode 100644
new mode 100755
similarity index 99%
rename from aliyun-oss-php-sdk-2.3.1/README-CN.md
rename to aliyun-oss-php-sdk-2.4.3/README-CN.md
index 8c0cf84..89c1e5a
--- a/aliyun-oss-php-sdk-2.3.1/README-CN.md
+++ b/aliyun-oss-php-sdk-2.4.3/README-CN.md
@@ -111,7 +111,7 @@ OssClient提供的接口返回返回数据分为两种:
$bucketListInfo = $ossClient->listBuckets();
$bucketList = $bucketListInfo->getBucketList();
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`
diff --git a/aliyun-oss-php-sdk-2.3.1/README.md b/aliyun-oss-php-sdk-2.4.3/README.md
old mode 100644
new mode 100755
similarity index 91%
rename from aliyun-oss-php-sdk-2.3.1/README.md
rename to aliyun-oss-php-sdk-2.4.3/README.md
index 3c1da26..b77a356
--- a/aliyun-oss-php-sdk-2.3.1/README.md
+++ b/aliyun-oss-php-sdk-2.4.3/README.md
@@ -1,4 +1,4 @@
-# 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)
[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk)
@@ -50,12 +50,12 @@ Tips:
| Class | Explanation |
|:------------------|:------------------------------------|
-|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\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. |
-### 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
listBuckets();
$bucketList = $bucketListInfo->getBucketList();
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.
diff --git a/aliyun-oss-php-sdk-2.3.1/autoload.php b/aliyun-oss-php-sdk-2.4.3/autoload.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/autoload.php
rename to aliyun-oss-php-sdk-2.4.3/autoload.php
diff --git a/aliyun-oss-php-sdk-2.3.1/build-phar.sh b/aliyun-oss-php-sdk-2.4.3/build-phar.sh
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/build-phar.sh
rename to aliyun-oss-php-sdk-2.4.3/build-phar.sh
diff --git a/aliyun-oss-php-sdk-2.3.1/composer.json b/aliyun-oss-php-sdk-2.4.3/composer.json
old mode 100644
new mode 100755
similarity index 86%
rename from aliyun-oss-php-sdk-2.3.1/composer.json
rename to aliyun-oss-php-sdk-2.4.3/composer.json
index 1ecb58c..29e280b
--- a/aliyun-oss-php-sdk-2.3.1/composer.json
+++ b/aliyun-oss-php-sdk-2.4.3/composer.json
@@ -14,8 +14,8 @@
"php":">=5.3"
},
"require-dev" : {
- "phpunit/phpunit": "~4.0",
- "satooshi/php-coveralls": "~1.0"
+ "phpunit/phpunit": "*",
+ "satooshi/php-coveralls": "*"
},
"minimum-stability": "stable",
"autoload": {
diff --git a/aliyun-oss-php-sdk-2.3.1/example.jpg b/aliyun-oss-php-sdk-2.4.3/example.jpg
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/example.jpg
rename to aliyun-oss-php-sdk-2.4.3/example.jpg
diff --git a/aliyun-oss-php-sdk-2.3.1/index.php b/aliyun-oss-php-sdk-2.4.3/index.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/index.php
rename to aliyun-oss-php-sdk-2.4.3/index.php
diff --git a/aliyun-oss-php-sdk-2.3.1/phpunit.xml b/aliyun-oss-php-sdk-2.4.3/phpunit.xml
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/phpunit.xml
rename to aliyun-oss-php-sdk-2.4.3/phpunit.xml
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/Bucket.php b/aliyun-oss-php-sdk-2.4.3/samples/Bucket.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/Bucket.php
rename to aliyun-oss-php-sdk-2.4.3/samples/Bucket.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/BucketCors.php b/aliyun-oss-php-sdk-2.4.3/samples/BucketCors.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/BucketCors.php
rename to aliyun-oss-php-sdk-2.4.3/samples/BucketCors.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/BucketLifecycle.php b/aliyun-oss-php-sdk-2.4.3/samples/BucketLifecycle.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/BucketLifecycle.php
rename to aliyun-oss-php-sdk-2.4.3/samples/BucketLifecycle.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/BucketLogging.php b/aliyun-oss-php-sdk-2.4.3/samples/BucketLogging.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/BucketLogging.php
rename to aliyun-oss-php-sdk-2.4.3/samples/BucketLogging.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/BucketReferer.php b/aliyun-oss-php-sdk-2.4.3/samples/BucketReferer.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/BucketReferer.php
rename to aliyun-oss-php-sdk-2.4.3/samples/BucketReferer.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/BucketWebsite.php b/aliyun-oss-php-sdk-2.4.3/samples/BucketWebsite.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/BucketWebsite.php
rename to aliyun-oss-php-sdk-2.4.3/samples/BucketWebsite.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/Callback.php b/aliyun-oss-php-sdk-2.4.3/samples/Callback.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/Callback.php
rename to aliyun-oss-php-sdk-2.4.3/samples/Callback.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/Common.php b/aliyun-oss-php-sdk-2.4.3/samples/Common.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/Common.php
rename to aliyun-oss-php-sdk-2.4.3/samples/Common.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/Config.php b/aliyun-oss-php-sdk-2.4.3/samples/Config.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/Config.php
rename to aliyun-oss-php-sdk-2.4.3/samples/Config.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/Image.php b/aliyun-oss-php-sdk-2.4.3/samples/Image.php
old mode 100644
new mode 100755
similarity index 97%
rename from aliyun-oss-php-sdk-2.3.1/samples/Image.php
rename to aliyun-oss-php-sdk-2.4.3/samples/Image.php
index 6e51d06..8531733
--- a/aliyun-oss-php-sdk-2.3.1/samples/Image.php
+++ b/aliyun-oss-php-sdk-2.4.3/samples/Image.php
@@ -83,5 +83,5 @@ function printImage($func, $imageFile)
Common::println("$func, image width: " . $array[0]);
Common::println("$func, image height: " . $array[1]);
Common::println("$func, image type: " . ($array[2] === 2 ? 'jpg' : 'png'));
- Common::println("$func, image size: " . ceil(filesize($imageFile)));
+ Common::println("$func, image size: " . ceil(sprintf('%u',filesize($imageFile))));
}
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/LiveChannel.php b/aliyun-oss-php-sdk-2.4.3/samples/LiveChannel.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/LiveChannel.php
rename to aliyun-oss-php-sdk-2.4.3/samples/LiveChannel.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/MultipartUpload.php b/aliyun-oss-php-sdk-2.4.3/samples/MultipartUpload.php
old mode 100644
new mode 100755
similarity index 98%
rename from aliyun-oss-php-sdk-2.3.1/samples/MultipartUpload.php
rename to aliyun-oss-php-sdk-2.4.3/samples/MultipartUpload.php
index 21756b7..dd4b7fd
--- a/aliyun-oss-php-sdk-2.3.1/samples/MultipartUpload.php
+++ b/aliyun-oss-php-sdk-2.4.3/samples/MultipartUpload.php
@@ -85,7 +85,7 @@ function putObjectByRawApis($ossClient, $bucket)
*/
$partSize = 10 * 1024 * 1024;
$uploadFile = __FILE__;
- $uploadFileSize = filesize($uploadFile);
+ $uploadFileSize = sprintf('%u',filesize($uploadFile));
$pieces = $ossClient->generateMultiuploadParts($uploadFileSize, $partSize);
$responseUploadPart = array();
$uploadPosition = 0;
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/Object.php b/aliyun-oss-php-sdk-2.4.3/samples/Object.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/Object.php
rename to aliyun-oss-php-sdk-2.4.3/samples/Object.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/RunAll.php b/aliyun-oss-php-sdk-2.4.3/samples/RunAll.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/samples/RunAll.php
rename to aliyun-oss-php-sdk-2.4.3/samples/RunAll.php
diff --git a/aliyun-oss-php-sdk-2.3.1/samples/Signature.php b/aliyun-oss-php-sdk-2.4.3/samples/Signature.php
old mode 100644
new mode 100755
similarity index 98%
rename from aliyun-oss-php-sdk-2.3.1/samples/Signature.php
rename to aliyun-oss-php-sdk-2.4.3/samples/Signature.php
index eef5981..6388f27
--- a/aliyun-oss-php-sdk-2.3.1/samples/Signature.php
+++ b/aliyun-oss-php-sdk-2.4.3/samples/Signature.php
@@ -130,7 +130,7 @@ function getSignedUrlForPuttingObjectFromFile($ossClient, $bucket)
$request->set_method('PUT');
$request->add_header('Content-Type', 'txt');
$request->set_read_file($file);
- $request->set_read_stream_size(filesize($file));
+ $request->set_read_stream_size(sprintf('%u',filesize($file)));
$request->send_request();
$res = new ResponseCore($request->get_response_header(),
$request->get_response_body(), $request->get_response_code());
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Core/MimeTypes.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Core/MimeTypes.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Core/MimeTypes.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Core/MimeTypes.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Core/OssException.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Core/OssException.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Core/OssException.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Core/OssException.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Core/OssUtil.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Core/OssUtil.php
old mode 100644
new mode 100755
similarity index 92%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Core/OssUtil.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Core/OssUtil.php
index 541d2c3..a33a152
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Core/OssUtil.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Core/OssUtil.php
@@ -145,7 +145,7 @@ class OssUtil
public static function validateObject($object)
{
$pattern = '/^.{1,1023}$/';
- if (empty($object) || !preg_match($pattern, $object) ||
+ if (!preg_match($pattern, $object) ||
self::startsWith($object, '/') || self::startsWith($object, '\\')
) {
return false;
@@ -223,6 +223,8 @@ class OssUtil
public static function throwOssExceptionWithMessageIfEmpty($name, $errMsg)
{
if (empty($name)) {
+ if (is_string($name) && $name == '0')
+ return;
throw new OssException($errMsg);
}
}
@@ -235,7 +237,7 @@ class OssUtil
*/
public static function generateFile($filename, $size)
{
- if (file_exists($filename) && $size == filesize($filename)) {
+ if (file_exists($filename) && $size == sprintf('%u',filesize($filename))) {
echo $filename . " already exists, no need to create again. ";
return;
}
@@ -282,7 +284,7 @@ BBB;
if (($to_pos - $from_pos) > self::OSS_MAX_PART_SIZE) {
return $content_md5;
}
- $filesize = filesize($filename);
+ $filesize = sprintf('%u',filesize($filename));
if ($from_pos >= $filesize || $to_pos >= $filesize || $from_pos < 0 || $to_pos < 0) {
return $content_md5;
}
@@ -395,7 +397,11 @@ BBB;
if ($pos !== false) {
$str = substr($str, $pos+1);
}
-
+
+ if (!preg_match('/^[\w.-]+(:[0-9]+)?$/', $str)) {
+ throw new OssException("endpoint is invalid:" . $endpoint);
+ }
+
return $str;
}
@@ -418,6 +424,29 @@ BBB;
return $xml->asXML();
}
+ /**
+ * Generate the xml message of DeleteMultiObjects.
+ *
+ * @param DeleteObjectInfo[] $objects
+ * @param bool $quiet
+ * @return string
+ */
+ public static function createDeleteObjectVersionsXmlBody($objects, $quiet)
+ {
+ $xml = new \SimpleXMLElement('');
+ $xml->addChild('Quiet', $quiet);
+ foreach ($objects as $object) {
+ $sub_object = $xml->addChild('Object');
+ $key = OssUtil::sReplace($object->getKey());
+ $sub_object->addChild('Key', $key);
+ $versionId = $object->getVersionId();
+ if (!empty($versionId)) {
+ $sub_object->addChild('VersionId', $object->getVersionId());
+ }
+ }
+ return $xml->asXML();
+ }
+
/**
* Generate the xml message of CompleteMultipartUpload.
*
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Http/LICENSE b/aliyun-oss-php-sdk-2.4.3/src/OSS/Http/LICENSE
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Http/LICENSE
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Http/LICENSE
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Http/RequestCore.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Http/RequestCore.php
old mode 100644
new mode 100755
similarity index 98%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Http/RequestCore.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Http/RequestCore.php
index e1d221e..c8089b4
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Http/RequestCore.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Http/RequestCore.php
@@ -713,6 +713,8 @@ class RequestCore
$temp_headers[] = $k . ': ' . $v;
}
+ // fix "Expect: 100-continue"
+ $temp_headers[] = 'Expect:';
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $temp_headers);
}
@@ -775,7 +777,7 @@ class RequestCore
* data stored in the `curl_handle` and `response` properties unless replacement data is passed in via
* parameters.
*
- * @param resource $curl_handle (Optional) The reference to the already executed cURL request.
+ * @param resource|\CurlHandle|null|false $curl_handle (Optional) The reference to the already executed cURL request. Receive CurlHandle instance from PHP8.0
* @param string $response (Optional) The actual response content itself that needs to be parsed.
* @return ResponseCore A object containing a parsed HTTP response.
*/
@@ -786,8 +788,8 @@ class RequestCore
$this->response = $response;
}
- // As long as this came back as a valid resource...
- if (is_resource($curl_handle)) {
+ // As long as this came back as a valid resource or CurlHandle instance...
+ if (is_resource($curl_handle) || (is_object($curl_handle) && get_class($curl_handle) === 'CurlHandle')) {
// Determine what's what.
$header_size = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE);
$this->response_headers = substr($this->response, 0, $header_size);
@@ -842,12 +844,13 @@ class RequestCore
$this->response = curl_exec($curl_handle);
if ($this->response === false) {
- throw new RequestCore_Exception('cURL resource: ' . (string)$curl_handle . '; cURL error: ' . curl_error($curl_handle) . ' (' . curl_errno($curl_handle) . ')');
+ throw new RequestCore_Exception('cURL error: ' . curl_error($curl_handle) . ' (' . curl_errno($curl_handle) . ')');
}
$parsed_response = $this->process_response($curl_handle, $this->response);
curl_close($curl_handle);
+ unset($curl_handle);
if ($parse) {
return $parsed_response;
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Http/RequestCore_Exception.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Http/RequestCore_Exception.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Http/RequestCore_Exception.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Http/RequestCore_Exception.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Http/ResponseCore.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Http/ResponseCore.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Http/ResponseCore.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Http/ResponseCore.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/BucketInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/BucketInfo.php
new file mode 100755
index 0000000..e211eed
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/BucketInfo.php
@@ -0,0 +1,181 @@
+location = $location;
+ $this->createDate = $createDate;
+ $this->name = $name;
+ }
+
+ /**
+ * Get bucket location
+ *
+ * @return string
+ */
+ public function getLocation()
+ {
+ return $this->location;
+ }
+
+ /**
+ * Get bucket name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Get bucket creation time.
+ *
+ * @return string
+ */
+ public function getCreateDate()
+ {
+ 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
+ *
+ * @var string
+ */
+ private $location;
+ /**
+ * bucket name
+ *
+ * @var string
+ */
+ private $name;
+
+ /**
+ * bucket creation time
+ *
+ * @var string
+ */
+ 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;
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/BucketListInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/BucketListInfo.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/BucketListInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/BucketListInfo.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/BucketStat.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/BucketStat.php
new file mode 100755
index 0000000..9e2989a
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/BucketStat.php
@@ -0,0 +1,85 @@
+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;
+
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/CnameConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/CnameConfig.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/CnameConfig.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/CnameConfig.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/CorsConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/CorsConfig.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/CorsConfig.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/CorsConfig.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/CorsRule.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/CorsRule.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/CorsRule.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/CorsRule.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/DeleteMarkerInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/DeleteMarkerInfo.php
new file mode 100755
index 0000000..c129e99
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/DeleteMarkerInfo.php
@@ -0,0 +1,65 @@
+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 = "";
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/DeleteObjectInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/DeleteObjectInfo.php
new file mode 100755
index 0000000..806eafb
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/DeleteObjectInfo.php
@@ -0,0 +1,41 @@
+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 = "";
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/DeletedObjectInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/DeletedObjectInfo.php
new file mode 100755
index 0000000..6bba39a
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/DeletedObjectInfo.php
@@ -0,0 +1,63 @@
+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 = "";
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ExtendWormConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ExtendWormConfig.php
new file mode 100755
index 0000000..5e62287
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ExtendWormConfig.php
@@ -0,0 +1,64 @@
+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('');
+ 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;
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/GetLiveChannelHistory.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/GetLiveChannelHistory.php
old mode 100644
new mode 100755
similarity index 96%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/GetLiveChannelHistory.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/GetLiveChannelHistory.php
index 6643444..e6d518a
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/GetLiveChannelHistory.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/GetLiveChannelHistory.php
@@ -1,6 +1,9 @@
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('');
+ 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;
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LifecycleAction.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LifecycleAction.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LifecycleAction.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LifecycleAction.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LifecycleConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LifecycleConfig.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LifecycleConfig.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LifecycleConfig.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LifecycleRule.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LifecycleRule.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LifecycleRule.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LifecycleRule.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/ListMultipartUploadInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ListMultipartUploadInfo.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/ListMultipartUploadInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ListMultipartUploadInfo.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/ListPartsInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ListPartsInfo.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/ListPartsInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ListPartsInfo.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LiveChannelConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LiveChannelConfig.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LiveChannelConfig.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LiveChannelConfig.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LiveChannelHistory.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LiveChannelHistory.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LiveChannelHistory.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LiveChannelHistory.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LiveChannelInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LiveChannelInfo.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LiveChannelInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LiveChannelInfo.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LiveChannelListInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LiveChannelListInfo.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LiveChannelListInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LiveChannelListInfo.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LoggingConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LoggingConfig.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/LoggingConfig.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/LoggingConfig.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/ObjectInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectInfo.php
old mode 100644
new mode 100755
similarity index 84%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/ObjectInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectInfo.php
index 891f862..4adab3c
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/ObjectInfo.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectInfo.php
@@ -23,7 +23,7 @@ class ObjectInfo
* @param string $lastModified
* @param string $eTag
* @param string $type
- * @param int $size
+ * @param string $size
* @param string $storageClass
*/
public function __construct($key, $lastModified, $eTag, $type, $size, $storageClass)
@@ -67,15 +67,26 @@ class ObjectInfo
{
return $this->type;
}
-
- /**
- * @return int
- */
- public function getSize()
- {
- return $this->size;
- }
-
+
+ /**
+ * php7 && 64bit can use it
+ * @return int
+ */
+ public function getSize()
+ {
+ return (int)$this->size;
+ }
+
+
+ /**
+ * php5.x or 32bit must use it
+ * @return string
+ */
+ public function getSizeStr()
+ {
+ return $this->size;
+ }
+
/**
* @return string
*/
@@ -88,6 +99,6 @@ class ObjectInfo
private $lastModified = "";
private $eTag = "";
private $type = "";
- private $size = 0;
+ private $size = "0";
private $storageClass = "";
}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/ObjectListInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectListInfo.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/ObjectListInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectListInfo.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectVersionInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectVersionInfo.php
new file mode 100755
index 0000000..663bd0b
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectVersionInfo.php
@@ -0,0 +1,125 @@
+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;
+ }
+
+ /**
+ * php7 && 64bit can use it
+ * @return int
+ */
+ public function getSize()
+ {
+ return (int)$this->size;
+ }
+
+
+ /**
+ * php5.x or 32bit must use it
+ * @return string
+ */
+ public function getSizeStr()
+ {
+ 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 = "";
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectVersionListInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectVersionListInfo.php
new file mode 100755
index 0000000..c94210d
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ObjectVersionListInfo.php
@@ -0,0 +1,162 @@
+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();
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/PartInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/PartInfo.php
old mode 100644
new mode 100755
similarity index 80%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/PartInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/PartInfo.php
index 439a84d..07df576
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/PartInfo.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/PartInfo.php
@@ -14,7 +14,7 @@ class PartInfo
* @param int $partNumber
* @param string $lastModified
* @param string $eTag
- * @param int $size
+ * @param string $size
*/
public function __construct($partNumber, $lastModified, $eTag, $size)
{
@@ -49,15 +49,26 @@ class PartInfo
}
/**
+ * php7 && 64bit can use it
* @return int
*/
public function getSize()
{
- return $this->size;
+ return (int)$this->size;
}
+
+
+ /**
+ * php5.x or 32bit must use it
+ * @return string
+ */
+ public function getSizeStr()
+ {
+ return $this->size;
+ }
private $partNumber = 0;
private $lastModified = "";
private $eTag = "";
- private $size = 0;
+ private $size = "0";
}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/PrefixInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/PrefixInfo.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/PrefixInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/PrefixInfo.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/RefererConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/RefererConfig.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/RefererConfig.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/RefererConfig.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/RequestPaymentConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/RequestPaymentConfig.php
new file mode 100755
index 0000000..6b32060
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/RequestPaymentConfig.php
@@ -0,0 +1,68 @@
+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('');
+ 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 = "";
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/RestoreConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/RestoreConfig.php
new file mode 100755
index 0000000..156852a
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/RestoreConfig.php
@@ -0,0 +1,77 @@
+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->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';
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ServerSideEncryptionConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ServerSideEncryptionConfig.php
new file mode 100755
index 0000000..e3a190b
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/ServerSideEncryptionConfig.php
@@ -0,0 +1,91 @@
+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('');
+ $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 = "";
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/StorageCapacityConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/StorageCapacityConfig.php
old mode 100644
new mode 100755
similarity index 98%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/StorageCapacityConfig.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/StorageCapacityConfig.php
index 024b5c9..39a9e72
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/StorageCapacityConfig.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/StorageCapacityConfig.php
@@ -2,6 +2,8 @@
namespace OSS\Model;
+use OSS\Core\OssException;
+
/**
* Class StorageCapacityConfig
*
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/Tag.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/Tag.php
new file mode 100755
index 0000000..509bd6e
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/Tag.php
@@ -0,0 +1,41 @@
+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 = "";
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/TaggingConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/TaggingConfig.php
new file mode 100755
index 0000000..09fa323
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/TaggingConfig.php
@@ -0,0 +1,89 @@
+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('');
+ $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();
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/UploadInfo.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/UploadInfo.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/UploadInfo.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/UploadInfo.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/VersioningConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/VersioningConfig.php
new file mode 100755
index 0000000..992a80f
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/VersioningConfig.php
@@ -0,0 +1,67 @@
+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('');
+ 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 = "";
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/WebsiteConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/WebsiteConfig.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/WebsiteConfig.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/WebsiteConfig.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/WormConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/WormConfig.php
new file mode 100755
index 0000000..6a48956
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/WormConfig.php
@@ -0,0 +1,90 @@
+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;
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Model/XmlConfig.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Model/XmlConfig.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Model/XmlConfig.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Model/XmlConfig.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/OssClient.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/OssClient.php
old mode 100644
new mode 100755
similarity index 75%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/OssClient.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/OssClient.php
index daae42c..0922a0b
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/OssClient.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/OssClient.php
@@ -50,6 +50,28 @@ use OSS\Model\RefererConfig;
use OSS\Model\WebsiteConfig;
use OSS\Core\OssUtil;
use OSS\Model\ListPartsInfo;
+use OSS\Result\GetBucketInfoResult;
+use OSS\Model\BucketStat;
+use OSS\Result\GetBucketStatResult;
+use OSS\Model\ServerSideEncryptionConfig;
+use OSS\Result\GetBucketEncryptionResult;
+use OSS\Model\RequestPaymentConfig;
+use OSS\Result\GetBucketRequestPaymentResult;
+use OSS\Model\Tag;
+use OSS\Model\TaggingConfig;
+use OSS\Result\GetBucketTagsResult;
+use OSS\Model\VersioningConfig;
+use OSS\Result\GetBucketVersioningResult;
+use OSS\Model\InitiateWormConfig;
+use OSS\Result\InitiateBucketWormResult;
+use OSS\Model\ExtendWormConfig;
+use OSS\Result\GetBucketWormResult;
+use OSS\Model\RestoreConfig;
+use OSS\Model\ObjectVersionListInfo;
+use OSS\Result\ListObjectVersionsResult;
+use OSS\Model\DeleteObjectInfo;
+use OSS\Model\DeletedObjectInfo;
+use OSS\Result\DeleteObjectVersionsResult;
/**
* Class OssClient
@@ -273,12 +295,12 @@ class OssClient
*
* @param string $bucket
* @param string $object
+ * @param array $options
* @throws OssException
* @return string
*/
- public function getObjectAcl($bucket, $object)
+ public function getObjectAcl($bucket, $object, $options = NULL)
{
- $options = array();
$this->precheckCommon($bucket, $object, $options, true);
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_BUCKET] = $bucket;
@@ -295,10 +317,11 @@ class OssClient
* @param string $bucket bucket name
* @param string $object object name
* @param string $acl access permissions, valid values are ['default', 'private', 'public-read', 'public-read-write']
+ * @param array $options
* @throws OssException
* @return null
*/
- public function putObjectAcl($bucket, $object, $acl)
+ public function putObjectAcl($bucket, $object, $acl, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options, true);
$options[self::OSS_BUCKET] = $bucket;
@@ -685,7 +708,7 @@ class OssClient
* @throws OssException
* @return GetLiveChannelHistory
*/
- public function getLiveChannelHistory($bucket, $channelName, $options = NULL)
+ public function getLiveChannelHistory($bucket, $channelName, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
@@ -810,6 +833,41 @@ class OssClient
return $proto . $hostname . '/live/' . $channelName . '?' . implode('&', $query_items);
}
+ /**
+ * Generates the signed pushing streaming url
+ *
+ * @param string $bucket bucket name
+ * @param string $channelName channel name
+ * @param int $expiration expiration time of the Url, unix epoch, since 1970.1.1 00.00.00 UTC
+ * @param array $options
+ * @throws OssException
+ * @return The signed pushing streaming url
+ */
+ public function generatePresignedRtmpUrl($bucket, $channelName, $expiration, $options = NULL)
+ {
+ $this->precheckCommon($bucket, $channelName, $options, false);
+ $proto = 'rtmp://';
+ $hostname = $this->generateHostname($bucket);
+ $cano_params = '';
+ $query_items = array();
+ $params = isset($options['params']) ? $options['params'] : array();
+ uksort($params, 'strnatcasecmp');
+ foreach ($params as $key => $value) {
+ $cano_params = $cano_params . $key . ':' . $value . "\n";
+ $query_items[] = rawurlencode($key) . '=' . rawurlencode($value);
+ }
+ $resource = '/' . $bucket . '/' . $channelName;
+
+ $string_to_sign = $expiration . "\n" . $cano_params . $resource;
+ $signature = base64_encode(hash_hmac('sha1', $string_to_sign, $this->accessKeySecret, true));
+
+ $query_items[] = 'OSSAccessKeyId=' . rawurlencode($this->accessKeyId);
+ $query_items[] = 'Expires=' . rawurlencode($expiration);
+ $query_items[] = 'Signature=' . rawurlencode($signature);
+
+ return $proto . $hostname . '/live/' . $channelName . '?' . implode('&', $query_items);
+ }
+
/**
* Precheck the CORS request. Before sending a CORS request, a preflight request (OPTIONS) is sent with the specific origin.
* HTTP METHOD and headers information are sent to OSS as well for evaluating if the CORS request is allowed.
@@ -950,7 +1008,6 @@ class OssClient
return $result->getData();
}
-
/**
* Set the size of the bucket,the unit is GB
* When the capacity of the bucket is bigger than the set, it's forbidden to continue writing
@@ -996,6 +1053,445 @@ class OssClient
return $result->getData();
}
+ /**
+ * Get the information of the bucket
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return BucketInfo
+ */
+ public function getBucketInfo($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'bucketInfo';
+ $response = $this->auth($options);
+ $result = new GetBucketInfoResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Get the stat of the bucket
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return BucketStat
+ */
+ public function getBucketStat($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'stat';
+ $response = $this->auth($options);
+ $result = new GetBucketStatResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Sets the bucket's policy
+ *
+ * @param string $bucket bucket name
+ * @param string $policy policy json format content
+ * @param array $options
+ * @throws OssException
+ * @return null
+ */
+ public function putBucketPolicy($bucket, $policy, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'policy';
+ $options[self::OSS_CONTENT_TYPE] = 'application/json';
+ $options[self::OSS_CONTENT] = $policy;
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Gets bucket's policy
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return string policy json content
+ */
+ public function getBucketPolicy($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'policy';
+ $response = $this->auth($options);
+ $result = new BodyResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Deletes the bucket's policy
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return null
+ */
+ public function deleteBucketPolicy($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'policy';
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Sets the bucket's encryption
+ *
+ * @param string $bucket bucket name
+ * @param ServerSideEncryptionConfig $sseConfig
+ * @param array $options
+ * @throws OssException
+ * @return null
+ */
+ public function putBucketEncryption($bucket, $sseConfig, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'encryption';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $options[self::OSS_CONTENT] = $sseConfig->serializeToXml();
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Gets bucket's encryption
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return ServerSideEncryptionConfig
+ */
+ public function getBucketEncryption($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'encryption';
+ $response = $this->auth($options);
+ $result = new GetBucketEncryptionResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Deletes the bucket's encryption
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return null
+ */
+ public function deleteBucketEncryption($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'encryption';
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Set the request playment of the bucket, Can be BucketOwner and Requester
+ *
+ * @param string $bucket bucket name
+ * @param string $payer
+ * @param array $options
+ * @return ResponseCore
+ * @throws null
+ */
+ public function putBucketRequestPayment($bucket, $payer, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'requestPayment';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $config = new RequestPaymentConfig($payer);
+ $options[self::OSS_CONTENT] = $config->serializeToXml();
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Get the request playment of the bucket
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return string
+ */
+ public function getBucketRequestPayment($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'requestPayment';
+ $response = $this->auth($options);
+ $result = new GetBucketRequestPaymentResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Sets the bucket's tags
+ *
+ * @param string $bucket bucket name
+ * @param TaggingConfig $taggingConfig
+ * @param array $options
+ * @throws OssException
+ * @return null
+ */
+ public function putBucketTags($bucket, $taggingConfig, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING;
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $options[self::OSS_CONTENT] = $taggingConfig->serializeToXml();
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Gets bucket's tags
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return TaggingConfig
+ */
+ public function getBucketTags($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING;
+ $response = $this->auth($options);
+ $result = new GetBucketTagsResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Deletes the bucket's tags
+ * If want to delete specified tags for a bucket, please set the $tags
+ *
+ * @param string $bucket bucket name
+ * @param tag[] $tags (optional)
+ * @param array $options
+ * @throws OssException
+ * @return null
+ */
+ public function deleteBucketTags($bucket, $tags = NULL, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE;
+ $options[self::OSS_OBJECT] = '/';
+ if (empty($tags)) {
+ $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING;
+ } else {
+ $value = '';
+ foreach ($tags as $tag ) {
+ $value .= $tag->getKey().',';
+ }
+ $value = rtrim($value, ',');
+ $options[self::OSS_TAGGING] = $value;
+ }
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Set the versioning of the bucket, Can be BucketOwner and Requester
+ *
+ * @param string $bucket bucket name
+ * @param string $status
+ * @param array $options
+ * @return ResponseCore
+ * @throws null
+ */
+ public function putBucketVersioning($bucket, $status, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'versioning';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $config = new VersioningConfig($status);
+ $options[self::OSS_CONTENT] = $config->serializeToXml();
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Get the versioning of the bucket
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return string
+ */
+ public function getBucketVersioning($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'versioning';
+ $response = $this->auth($options);
+ $result = new GetBucketVersioningResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Initialize a bucket's worm
+ *
+ * @param string $bucket bucket name
+ * @param int $day
+ * @param array $options
+ * @throws OssException
+ * @return string returns uploadid
+ */
+ public function initiateBucketWorm($bucket, $day, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_METHOD] = self::OSS_HTTP_POST;
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'worm';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $config = new InitiateWormConfig($day);
+ $options[self::OSS_CONTENT] = $config->serializeToXml();
+ $response = $this->auth($options);
+ $result = new InitiateBucketWormResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Aborts the bucket's worm
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return null
+ */
+ public function abortBucketWorm($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'worm';
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Complete a bucket's worm
+ *
+ * @param string $bucket bucket name
+ * @param string $wormId
+ * @param array $options
+ * @throws OssException
+ * @return string returns uploadid
+ */
+ public function completeBucketWorm($bucket, $wormId, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_METHOD] = self::OSS_HTTP_POST;
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_WORM_ID] = $wormId;
+ $options[self::OSS_CONTENT] = '';
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Extend a bucket's worm
+ *
+ * @param string $bucket bucket name
+ * @param string $wormId
+ * @param int $day
+ * @param array $options
+ * @throws OssException
+ * @return string returns uploadid
+ */
+ public function extendBucketWorm($bucket, $wormId, $day, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_METHOD] = self::OSS_HTTP_POST;
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_WORM_ID] = $wormId;
+ $options[self::OSS_SUB_RESOURCE] = 'wormExtend';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $config = new ExtendWormConfig($day);
+ $options[self::OSS_CONTENT] = $config->serializeToXml();
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Get a bucket's worm
+ *
+ * @param string $bucket bucket name
+ * @param array $options
+ * @throws OssException
+ * @return string
+ */
+ public function getBucketWorm($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'worm';
+ $response = $this->auth($options);
+ $result = new GetBucketWormResult($response);
+ return $result->getData();
+ }
/**
* Lists the bucket's object list (in ObjectListInfo)
@@ -1018,16 +1514,14 @@ class OssClient
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_OBJECT] = '/';
- $options[self::OSS_HEADERS] = array(
- self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/',
- self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '',
- self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE,
- self::OSS_MARKER => isset($options[self::OSS_MARKER]) ? $options[self::OSS_MARKER] : '',
- );
$query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array();
$options[self::OSS_QUERY_STRING] = array_merge(
$query,
- array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL)
+ array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL,
+ self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/',
+ self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '',
+ self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE,
+ self::OSS_MARKER => isset($options[self::OSS_MARKER]) ? $options[self::OSS_MARKER] : '')
);
$response = $this->auth($options);
@@ -1035,6 +1529,45 @@ class OssClient
return $result->getData();
}
+ /**
+ * Lists the bucket's object with version information (in ObjectListInfo)
+ *
+ * @param string $bucket
+ * @param array $options are defined below:
+ * $options = array(
+ * 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000.
+ * 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix.
+ * 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjectVersions will differeniate the object and folder. And it will return subfolder's objects.
+ * 'key-marker' => The key of returned object must be greater than the 'key-marker'.
+ * 'version-id-marker' => The version id of returned object must be greater than the 'version-id-marker'.
+ *)
+ * Prefix and marker are for filtering and paging. Their length must be less than 256 bytes
+ * @throws OssException
+ * @return ObjectListInfo
+ */
+ public function listObjectVersions($bucket, $options = NULL)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'versions';
+ $query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array();
+ $options[self::OSS_QUERY_STRING] = array_merge(
+ $query,
+ array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL,
+ self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/',
+ self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '',
+ self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE,
+ self::OSS_KEY_MARKER => isset($options[self::OSS_KEY_MARKER]) ? $options[self::OSS_KEY_MARKER] : '',
+ self::OSS_VERSION_ID_MARKER => isset($options[self::OSS_VERSION_ID_MARKER]) ? $options[self::OSS_VERSION_ID_MARKER] : '')
+ );
+
+ $response = $this->auth($options);
+ $result = new ListObjectVersionsResult($response);
+ return $result->getData();
+ }
+
/**
* Creates a virtual 'folder' in OSS. The name should not end with '/' because the method will append the name with a '/' anyway.
*
@@ -1127,11 +1660,12 @@ class OssClient
/**
* gets symlink
- *@param string $bucket bucket name
+ * @param string $bucket bucket name
* @param string $symlink symlink name
+ * @param array $options
* @return null
*/
- public function getSymlink($bucket, $symlink)
+ public function getSymlink($bucket, $symlink, $options = NULL)
{
$this->precheckCommon($bucket, $symlink, $options);
@@ -1164,7 +1698,7 @@ class OssClient
throw new OssException($file . " file does not exist");
}
$options[self::OSS_FILE_UPLOAD] = $file;
- $file_size = filesize($options[self::OSS_FILE_UPLOAD]);
+ $file_size = sprintf('%u',filesize($options[self::OSS_FILE_UPLOAD]));
$is_check_md5 = $this->isCheckMD5($options);
if ($is_check_md5) {
$content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true));
@@ -1182,6 +1716,45 @@ class OssClient
return $result->getData();
}
+ /**
+ * Uploads object from file handle
+ *
+ * @param string $bucket bucket name
+ * @param string $object object name
+ * @param resource $handle file handle
+ * @param array $options
+ * @return null
+ * @throws OssException
+ */
+ public function uploadStream($bucket, $object, $handle, $options = NULL)
+ {
+ $this->precheckCommon($bucket, $object, $options);
+ if (!is_resource($handle)) {
+ throw new OssException("The handle must be an opened stream");
+ }
+ $options[self::OSS_FILE_UPLOAD] = $handle;
+ if ($this->isCheckMD5($options)) {
+ rewind($handle);
+ $ctx = hash_init('md5');
+ hash_update_stream($ctx, $handle);
+ $content_md5 = base64_encode(hash_final($ctx, true));
+ rewind($handle);
+ $options[self::OSS_CONTENT_MD5] = $content_md5;
+ }
+ if (!isset($options[self::OSS_CONTENT_TYPE])) {
+ $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object);
+ }
+ $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_OBJECT] = $object;
+ if (!isset($options[self::OSS_CONTENT_LENGTH])) {
+ $options[self::OSS_CONTENT_LENGTH] = fstat($handle)[self::OSS_SIZE];
+ }
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
/**
* Append the object with the content at the specified position.
* The specified position is typically the lengh of the current file.
@@ -1243,7 +1816,7 @@ class OssClient
throw new OssException($file . " file does not exist");
}
$options[self::OSS_FILE_UPLOAD] = $file;
- $file_size = filesize($options[self::OSS_FILE_UPLOAD]);
+ $file_size = sprintf('%u',filesize($options[self::OSS_FILE_UPLOAD]));
$is_check_md5 = $this->isCheckMD5($options);
if ($is_check_md5) {
$content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true));
@@ -1283,10 +1856,15 @@ class OssClient
$options[self::OSS_BUCKET] = $toBucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_OBJECT] = $toObject;
+ $param = '/' . $fromBucket . '/' . rawurlencode($fromObject);
+ if (isset($options[self::OSS_VERSION_ID])) {
+ $param = $param . '?versionId='.$options[self::OSS_VERSION_ID];
+ unset($options[self::OSS_VERSION_ID]);
+ }
if (isset($options[self::OSS_HEADERS])) {
- $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = '/' . $fromBucket . '/' . $fromObject;
+ $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = $param;
} else {
- $options[self::OSS_HEADERS] = array(self::OSS_OBJECT_COPY_SOURCE => '/' . $fromBucket . '/' . $fromObject);
+ $options[self::OSS_HEADERS] = array(self::OSS_OBJECT_COPY_SOURCE => $param);
}
$response = $this->auth($options);
$result = new CopyObjectResult($response);
@@ -1312,6 +1890,27 @@ class OssClient
return $result->getData();
}
+ /**
+ * Gets the simplified metadata of a object.
+ * Simplified metadata includes ETag, Size, LastModified.
+ *
+ * @param string $bucket bucket name
+ * @param string $object object name
+ * @param string $options Checks out the SDK document for the detail
+ * @return array
+ */
+ public function getSimplifiedObjectMeta($bucket, $object, $options = NULL)
+ {
+ $this->precheckCommon($bucket, $object, $options);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD;
+ $options[self::OSS_OBJECT] = $object;
+ $options[self::OSS_SUB_RESOURCE] = 'objectMeta';
+ $response = $this->auth($options);
+ $result = new HeaderResult($response);
+ return $result->getData();
+ }
+
/**
* Deletes a object
*
@@ -1366,6 +1965,41 @@ class OssClient
return $result->getData();
}
+ /**
+ * Deletes multiple objects with version id in a bucket
+ *
+ * @param string $bucket bucket name
+ * @param array $objects DeleteObjectInfo list
+ * @param array $options
+ * @return ResponseCore
+ * @throws null
+ */
+ public function deleteObjectVersions($bucket, $objects, $options = null)
+ {
+ $this->precheckCommon($bucket, NULL, $options, false);
+ if (!is_array($objects) || !$objects) {
+ throw new OssException('objects must be array');
+ }
+ $options[self::OSS_METHOD] = self::OSS_HTTP_POST;
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_OBJECT] = '/';
+ $options[self::OSS_SUB_RESOURCE] = 'delete';
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $quiet = 'false';
+ if (isset($options['quiet'])) {
+ if (is_bool($options['quiet'])) { //Boolean
+ $quiet = $options['quiet'] ? 'true' : 'false';
+ } elseif (is_string($options['quiet'])) { // string
+ $quiet = ($options['quiet'] === 'true') ? 'true' : 'false';
+ }
+ }
+ $xmlBody = OssUtil::createDeleteObjectVersionsXmlBody($objects, $quiet);
+ $options[self::OSS_CONTENT] = $xmlBody;
+ $response = $this->auth($options);
+ $result = new DeleteObjectVersionsResult($response);
+ return $result->getData();
+ }
+
/**
* Gets Object content
*
@@ -1434,11 +2068,101 @@ class OssClient
$options[self::OSS_METHOD] = self::OSS_HTTP_POST;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_SUB_RESOURCE] = self::OSS_RESTORE;
+ if (isset($options[self::OSS_RESTORE_CONFIG])) {
+ $config = $options[self::OSS_RESTORE_CONFIG];
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $options[self::OSS_CONTENT] = $config->serializeToXml();
+ }
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
}
+ /**
+ * Sets the object tagging
+ *
+ * @param string $bucket bucket name
+ * @param string $object object name
+ * @param TaggingConfig $taggingConfig
+ * @throws OssException
+ * @return null
+ */
+ public function putObjectTagging($bucket, $object, $taggingConfig, $options = NULL)
+ {
+ $this->precheckCommon($bucket, $object, $options, true);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
+ $options[self::OSS_OBJECT] = $object;
+ $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING;
+ $options[self::OSS_CONTENT_TYPE] = 'application/xml';
+ $options[self::OSS_CONTENT] = $taggingConfig->serializeToXml();
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Gets the object tagging
+ *
+ * @param string $bucket
+ * @param string $object
+ * @throws OssException
+ * @return TaggingConfig
+ */
+ public function getObjectTagging($bucket, $object, $options = NULL)
+ {
+ $this->precheckCommon($bucket, $object, $options, true);
+ $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_OBJECT] = $object;
+ $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING;
+ $response = $this->auth($options);
+ $result = new GetBucketTagsResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Deletes the object tagging
+ *
+ * @param string $bucket
+ * @param string $object
+ * @throws OssException
+ * @return TaggingConfig
+ */
+ public function deleteObjectTagging($bucket, $object, $options = NULL)
+ {
+ $this->precheckCommon($bucket, $object, $options, true);
+ $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE;
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_OBJECT] = $object;
+ $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING;
+ $response = $this->auth($options);
+ $result = new PutSetDeleteResult($response);
+ return $result->getData();
+ }
+
+ /**
+ * Processes the object
+ *
+ * @param string $bucket bucket name
+ * @param string $object object name
+ * @param string $process process script
+ * @return string process result, json format
+ */
+ public function processObject($bucket, $object, $process, $options = NULL)
+ {
+ $this->precheckCommon($bucket, $object, $options);
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_METHOD] = self::OSS_HTTP_POST;
+ $options[self::OSS_OBJECT] = $object;
+ $options[self::OSS_SUB_RESOURCE] = 'x-oss-process';
+ $options[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
+ $options[self::OSS_CONTENT] = 'x-oss-process='.$process;
+ $response = $this->auth($options);
+ $result = new BodyResult($response);
+ return $result->getData();
+ }
+
/**
* Gets the part size according to the preferred part size.
* If the specified part size is too small or too big, it will return a min part or max part size instead.
@@ -1693,7 +2417,13 @@ class OssClient
$options[self::OSS_HEADERS] = array();
}
- $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = '/' . $fromBucket . '/' . $fromObject;
+ $param = '/' . $fromBucket . '/' . rawurlencode($fromObject);
+ if (isset($options[self::OSS_VERSION_ID])) {
+ $param = $param . '?versionId='.$options[self::OSS_VERSION_ID];
+ unset($options[self::OSS_VERSION_ID]);
+ }
+
+ $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = $param;
$options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE_RANGE] = "bytes=" . $start_range . "-" . $end_range;
$response = $this->auth($options);
$result = new UploadPartResult($response);
@@ -1730,9 +2460,10 @@ class OssClient
if (isset($options[self::OSS_CONTENT_LENGTH])) {
$upload_file_size = (integer)$options[self::OSS_CONTENT_LENGTH];
} else {
- $upload_file_size = filesize($uploadFile);
+ $upload_file_size = sprintf('%u',filesize($uploadFile));
+
if ($upload_file_size !== false) {
- $upload_file_size -= $upload_position;
+ $upload_file_size -= $upload_position;
}
}
@@ -1787,7 +2518,16 @@ class OssClient
'ETag' => $etag,
);
}
- return $this->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts);
+
+ //build complete options
+ $cmp_options = null;
+ if (isset($options[self::OSS_HEADERS]) && isset($options[self::OSS_HEADERS][self::OSS_REQUEST_PAYER])) {
+ $cmp_options = array(
+ OssClient::OSS_HEADERS => array(
+ OssClient::OSS_REQUEST_PAYER => $options[self::OSS_HEADERS][self::OSS_REQUEST_PAYER],
+ ));
+ }
+ return $this->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts, $cmp_options);
}
/**
@@ -1871,6 +2611,37 @@ class OssClient
return $this->auth($options);
}
+ /**
+ * Sign URL with specified expiration time in seconds and HTTP method.
+ * The signed URL could be used to access the object directly.
+ *
+ * @param string $bucket
+ * @param string $object
+ * @param int $expiration expiration time of the Url, unix epoch, since 1970.1.1 00.00.00 UTC
+ * @param string $method
+ * @param array $options Key-Value array
+ * @return string
+ * @throws OssException
+ */
+ public function generatePresignedUrl($bucket, $object, $expiration, $method = self::OSS_HTTP_GET, $options = NULL)
+ {
+ $this->precheckCommon($bucket, $object, $options);
+ //method
+ if (self::OSS_HTTP_GET !== $method && self::OSS_HTTP_PUT !== $method) {
+ throw new OssException("method is invalid");
+ }
+ $options[self::OSS_BUCKET] = $bucket;
+ $options[self::OSS_OBJECT] = $object;
+ $options[self::OSS_METHOD] = $method;
+ if (!isset($options[self::OSS_CONTENT_TYPE])) {
+ $options[self::OSS_CONTENT_TYPE] = '';
+ }
+ $options[self::OSS_PREAUTH] = $expiration;
+ $options[self::OSS_DATE] = $expiration;
+ $this->setSignStsInUrl(true);
+ return $this->auth($options);
+ }
+
/**
* validates options. Create a empty array if it's NULL.
*
@@ -1924,6 +2695,8 @@ class OssClient
return;
case self::OSS_STORAGE_STANDARD:
return;
+ case self::OSS_STORAGE_COLDARCHIVE:
+ return;
default:
break;
}
@@ -2071,10 +2844,10 @@ class OssClient
$non_signable_resource .= $conjunction . $query_string;
$conjunction = '&';
}
- $this->requestUrl = $scheme . $hostname . $resource_uri . $signable_query_string . $non_signable_resource;
+ $requestUrl = $scheme . $hostname . $resource_uri . $signable_query_string . $non_signable_resource;
//Creates the request
- $request = new RequestCore($this->requestUrl, $this->requestProxy);
+ $request = new RequestCore($requestUrl, $this->requestProxy);
$request->set_useragent($this->generateUserAgent());
// Streaming uploads
if (isset($options[self::OSS_FILE_UPLOAD])) {
@@ -2159,19 +2932,22 @@ class OssClient
}
// Generates the signable_resource
$signable_resource = $this->generateSignableResource($options);
- $string_to_sign .= rawurldecode($signable_resource) . urldecode($signable_query_string);
+ $signable_resource = rawurldecode($signable_resource) . urldecode($signable_query_string);
+ $string_to_sign_ordered = $string_to_sign;
+ $string_to_sign .= $signable_resource;
// Sort the strings to be signed.
- $string_to_sign_ordered = $this->stringToSignSorted($string_to_sign);
+ $string_to_sign_ordered .= $this->stringToSignSorted($signable_resource);
+
$signature = base64_encode(hash_hmac('sha1', $string_to_sign_ordered, $this->accessKeySecret, true));
$request->add_header('Authorization', 'OSS ' . $this->accessKeyId . ':' . $signature);
if (isset($options[self::OSS_PREAUTH]) && (integer)$options[self::OSS_PREAUTH] > 0) {
- $signed_url = $this->requestUrl . $conjunction . self::OSS_URL_ACCESS_KEY_ID . '=' . rawurlencode($this->accessKeyId) . '&' . self::OSS_URL_EXPIRES . '=' . $options[self::OSS_PREAUTH] . '&' . self::OSS_URL_SIGNATURE . '=' . rawurlencode($signature);
+ $signed_url = $requestUrl . $conjunction . self::OSS_URL_ACCESS_KEY_ID . '=' . rawurlencode($this->accessKeyId) . '&' . self::OSS_URL_EXPIRES . '=' . $options[self::OSS_PREAUTH] . '&' . self::OSS_URL_SIGNATURE . '=' . rawurlencode($signature);
return $signed_url;
} elseif (isset($options[self::OSS_PREAUTH])) {
- return $this->requestUrl;
+ return $requestUrl;
}
if ($this->timeout !== 0) {
@@ -2187,7 +2963,7 @@ class OssClient
throw(new OssException('RequestCoreException: ' . $e->getMessage()));
}
$response_header = $request->get_response_header();
- $response_header['oss-request-url'] = $this->requestUrl;
+ $response_header['oss-request-url'] = $requestUrl;
$response_header['oss-redirects'] = $this->redirects;
$response_header['oss-stringtosign'] = $string_to_sign;
$response_header['oss-requestheaders'] = $request->request_headers;
@@ -2400,6 +3176,10 @@ class OssClient
self::OSS_POSITION,
self::OSS_SYMLINK,
self::OSS_RESTORE,
+ self::OSS_TAGGING,
+ self::OSS_WORM_ID,
+ self::OSS_TRAFFIC_LIMIT,
+ self::OSS_VERSION_ID,
);
foreach ($signableList as $item) {
@@ -2478,7 +3258,12 @@ class OssClient
$queryStringSorted = substr($queryStringSorted, 0, -1);
- return $explodeResult[0] . '?' . $queryStringSorted;
+ $result = '';
+ for ($i = 0; $i < $index -1; $i++)
+ {
+ $result .= $explodeResult[$i] . '?';
+ }
+ return $result . $queryStringSorted;
}
/**
@@ -2670,6 +3455,14 @@ class OssClient
const OSS_STORAGE_STANDARD = 'Standard';
const OSS_STORAGE_IA = 'IA';
const OSS_STORAGE_ARCHIVE = 'Archive';
+ const OSS_STORAGE_COLDARCHIVE = 'ColdArchive';
+ const OSS_TAGGING = 'tagging';
+ const OSS_WORM_ID = 'wormId';
+ const OSS_RESTORE_CONFIG = 'restore-config';
+ const OSS_KEY_MARKER = 'key-marker';
+ const OSS_VERSION_ID_MARKER = 'version-id-marker';
+ const OSS_VERSION_ID = 'versionId';
+ const OSS_HEADER_VERSION_ID = 'x-oss-version-id';
//private URLs
const OSS_URL_ACCESS_KEY_ID = 'OSSAccessKeyId';
@@ -2693,6 +3486,8 @@ class OssClient
const OSS_PROCESS = "x-oss-process";
const OSS_CALLBACK = "x-oss-callback";
const OSS_CALLBACK_VAR = "x-oss-callback-var";
+ const OSS_REQUEST_PAYER = "x-oss-request-payer";
+ const OSS_TRAFFIC_LIMIT = "x-oss-traffic-limit";
//Constants for STS SecurityToken
const OSS_SECURITY_TOKEN = "x-oss-security-token";
const OSS_ACL_TYPE_PRIVATE = 'private';
@@ -2714,8 +3509,8 @@ class OssClient
);
// OssClient version information
const OSS_NAME = "aliyun-sdk-php";
- const OSS_VERSION = "2.3.1";
- const OSS_BUILD = "20191115";
+ const OSS_VERSION = "2.4.3";
+ const OSS_BUILD = "20210825";
const OSS_AUTHOR = "";
const OSS_OPTIONS_ORIGIN = 'Origin';
const OSS_OPTIONS_REQUEST_METHOD = 'Access-Control-Request-Method';
@@ -2728,7 +3523,6 @@ class OssClient
// user's domain type. It could be one of the four: OSS_HOST_TYPE_NORMAL, OSS_HOST_TYPE_IP, OSS_HOST_TYPE_SPECIAL, OSS_HOST_TYPE_CNAME
private $hostType = self::OSS_HOST_TYPE_NORMAL;
- private $requestUrl;
private $requestProxy = null;
private $accessKeyId;
private $accessKeySecret;
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/AclResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/AclResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/AclResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/AclResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/AppendResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/AppendResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/AppendResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/AppendResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/BodyResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/BodyResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/BodyResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/BodyResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/CallbackResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/CallbackResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/CallbackResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/CallbackResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/CopyObjectResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/CopyObjectResult.php
old mode 100644
new mode 100755
similarity index 89%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/CopyObjectResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/CopyObjectResult.php
index 498723e..6ed67c6
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/CopyObjectResult.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/CopyObjectResult.php
@@ -25,6 +25,6 @@ class CopyObjectResult extends Result
$result[] = $xml->ETag;
}
- return $result;
+ return array_merge($result, $this->rawResponse->header);
}
}
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/DeleteObjectVersionsResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/DeleteObjectVersionsResult.php
new file mode 100755
index 0000000..69f52a7
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/DeleteObjectVersionsResult.php
@@ -0,0 +1,39 @@
+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;
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/DeleteObjectsResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/DeleteObjectsResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/DeleteObjectsResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/DeleteObjectsResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ExistResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ExistResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ExistResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ExistResult.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketEncryptionResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketEncryptionResult.php
new file mode 100755
index 0000000..3987cc9
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketEncryptionResult.php
@@ -0,0 +1,26 @@
+rawResponse->body;
+ $config = new ServerSideEncryptionConfig();
+ $config->parseFromXml($content);
+ return $config;
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketInfoResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketInfoResult.php
new file mode 100755
index 0000000..ad55e95
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketInfoResult.php
@@ -0,0 +1,37 @@
+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");
+ }
+ }
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketRequestPaymentResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketRequestPaymentResult.php
new file mode 100755
index 0000000..5107de3
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketRequestPaymentResult.php
@@ -0,0 +1,26 @@
+rawResponse->body;
+ $config = new RequestPaymentConfig();
+ $config->parseFromXml($content);
+ return $config->getPayer();
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketStatResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketStatResult.php
new file mode 100755
index 0000000..aa310cf
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketStatResult.php
@@ -0,0 +1,26 @@
+rawResponse->body;
+ $stat = new BucketStat();
+ $stat->parseFromXml($content);
+ return $stat;
+ }
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketTagsResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketTagsResult.php
new file mode 100755
index 0000000..59b4dd7
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketTagsResult.php
@@ -0,0 +1,26 @@
+rawResponse->body;
+ $config = new TaggingConfig();
+ $config->parseFromXml($content);
+ return $config;
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketVersioningResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketVersioningResult.php
new file mode 100755
index 0000000..225190c
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketVersioningResult.php
@@ -0,0 +1,26 @@
+rawResponse->body;
+ $config = new VersioningConfig();
+ $config->parseFromXml($content);
+ return $config->getStatus();
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketWormResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketWormResult.php
new file mode 100755
index 0000000..9587204
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetBucketWormResult.php
@@ -0,0 +1,26 @@
+rawResponse->body;
+ $config = new WormConfig();
+ $config->parseFromXml($content);
+ return $config;
+ }
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetCnameResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetCnameResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetCnameResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetCnameResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetCorsResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetCorsResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetCorsResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetCorsResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLifecycleResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLifecycleResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLifecycleResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLifecycleResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLiveChannelHistoryResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLiveChannelHistoryResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLiveChannelHistoryResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLiveChannelHistoryResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLiveChannelInfoResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLiveChannelInfoResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLiveChannelInfoResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLiveChannelInfoResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLiveChannelStatusResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLiveChannelStatusResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLiveChannelStatusResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLiveChannelStatusResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLocationResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLocationResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLocationResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLocationResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLoggingResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLoggingResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetLoggingResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetLoggingResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetRefererResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetRefererResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetRefererResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetRefererResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetStorageCapacityResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetStorageCapacityResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetStorageCapacityResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetStorageCapacityResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetWebsiteResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetWebsiteResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/GetWebsiteResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/GetWebsiteResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/HeaderResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/HeaderResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/HeaderResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/HeaderResult.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/InitiateBucketWormResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/InitiateBucketWormResult.php
new file mode 100755
index 0000000..1cd7a02
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/InitiateBucketWormResult.php
@@ -0,0 +1,27 @@
+rawResponse->header;
+ if (isset($header["x-oss-worm-id"])) {
+ return strval($header["x-oss-worm-id"]);
+ }
+ throw new OssException("cannot get worm-id");
+ }
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/InitiateMultipartUploadResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/InitiateMultipartUploadResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/InitiateMultipartUploadResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/InitiateMultipartUploadResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListBucketsResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListBucketsResult.php
old mode 100644
new mode 100755
similarity index 79%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListBucketsResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListBucketsResult.php
index a58fb2d..1dd037b
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListBucketsResult.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListBucketsResult.php
@@ -22,9 +22,8 @@ class ListBucketsResult extends Result
$xml = new \SimpleXMLElement($content);
if (isset($xml->Buckets) && isset($xml->Buckets->Bucket)) {
foreach ($xml->Buckets->Bucket as $bucket) {
- $bucketInfo = new BucketInfo(strval($bucket->Location),
- strval($bucket->Name),
- strval($bucket->CreationDate));
+ $bucketInfo = new BucketInfo();
+ $bucketInfo->parseFromXmlNode($bucket);
$bucketList[] = $bucketInfo;
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListLiveChannelResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListLiveChannelResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListLiveChannelResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListLiveChannelResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListMultipartUploadResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListMultipartUploadResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListMultipartUploadResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListMultipartUploadResult.php
diff --git a/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListObjectVersionsResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListObjectVersionsResult.php
new file mode 100755
index 0000000..849c21c
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListObjectVersionsResult.php
@@ -0,0 +1,96 @@
+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) ? strval($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;
+ }
+}
\ No newline at end of file
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListObjectsResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListObjectsResult.php
old mode 100644
new mode 100755
similarity index 97%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListObjectsResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListObjectsResult.php
index f44c66a..39f1f29
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListObjectsResult.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListObjectsResult.php
@@ -48,7 +48,7 @@ class ListObjectsResult extends Result
$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;
+ $size = isset($content->Size) ? strval($content->Size) : "0";
$storageClass = isset($content->StorageClass) ? strval($content->StorageClass) : "";
$retList[] = new ObjectInfo($key, $lastModified, $eTag, $type, $size, $storageClass);
}
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListPartsResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListPartsResult.php
old mode 100644
new mode 100755
similarity index 95%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListPartsResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListPartsResult.php
index 092d94e..6641b5b
--- a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/ListPartsResult.php
+++ b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/ListPartsResult.php
@@ -33,7 +33,7 @@ class ListPartsResult extends Result
$partNumber = isset($part->PartNumber) ? intval($part->PartNumber) : "";
$lastModified = isset($part->LastModified) ? strval($part->LastModified) : "";
$eTag = isset($part->ETag) ? strval($part->ETag) : "";
- $size = isset($part->Size) ? intval($part->Size) : "";
+ $size = isset($part->Size) ? strval($part->Size) : "";
$partList[] = new PartInfo($partNumber, $lastModified, $eTag, $size);
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/PutLiveChannelResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/PutLiveChannelResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/PutLiveChannelResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/PutLiveChannelResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/PutSetDeleteResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/PutSetDeleteResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/PutSetDeleteResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/PutSetDeleteResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/Result.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/Result.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/Result.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/Result.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/SymlinkResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/SymlinkResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/SymlinkResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/SymlinkResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/src/OSS/Result/UploadPartResult.php b/aliyun-oss-php-sdk-2.4.3/src/OSS/Result/UploadPartResult.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/src/OSS/Result/UploadPartResult.php
rename to aliyun-oss-php-sdk-2.4.3/src/OSS/Result/UploadPartResult.php
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/AclResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/AclResultTest.php
old mode 100644
new mode 100755
similarity index 96%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/AclResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/AclResultTest.php
index 12f4b1a..82168d0
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/AclResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/AclResultTest.php
@@ -6,7 +6,7 @@ use OSS\Result\AclResult;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
-class AclResultTest extends \PHPUnit_Framework_TestCase
+class AclResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<client = Common::getOssClient();
$this->bucketName = 'php-sdk-test-bucket-' . strval(rand(0, 10000));
$this->client->createBucket($this->bucketName);
}
- public function tearDown()
+ protected function tearDown(): void
{
$this->client->deleteBucket($this->bucketName);
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/BucketInfoTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/BucketInfoTest.php
old mode 100644
new mode 100755
similarity index 89%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/BucketInfoTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/BucketInfoTest.php
index 80fa25c..f99bcee
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/BucketInfoTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/BucketInfoTest.php
@@ -8,7 +8,7 @@ use OSS\Model\BucketInfo;
* Class BucketInfoTest
* @package OSS\Tests
*/
-class BucketInfoTest extends \PHPUnit_Framework_TestCase
+class BucketInfoTest extends \PHPUnit\Framework\TestCase
{
public function testConstruct()
{
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/BucketLiveChannelTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/BucketLiveChannelTest.php
old mode 100644
new mode 100755
similarity index 90%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/BucketLiveChannelTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/BucketLiveChannelTest.php
index bed68b0..cedf884
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/BucketLiveChannelTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/BucketLiveChannelTest.php
@@ -7,12 +7,12 @@ require_once __DIR__ . '/Common.php';
use OSS\Model\LiveChannelConfig;
use OSS\Core\OssException;
-class BucketLiveChannelTest extends \PHPUnit_Framework_TestCase
+class BucketLiveChannelTest extends \PHPUnit\Framework\TestCase
{
private $bucketName;
private $client;
- public function setUp()
+ protected function setUp(): void
{
$this->client = Common::getOssClient();
$this->bucketName = 'php-sdk-test-rtmp-bucket-name-' . strval(rand(0, 10000));
@@ -20,7 +20,7 @@ class BucketLiveChannelTest extends \PHPUnit_Framework_TestCase
Common::waitMetaSync();
}
- public function tearDown()
+ protected function tearDown(): void
{
////to delete created bucket
//1. delele live channel
@@ -195,6 +195,39 @@ class BucketLiveChannelTest extends \PHPUnit_Framework_TestCase
$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()
{
$channelName = 'live-to-put-status';
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CallbackTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CallbackTest.php
old mode 100644
new mode 100755
similarity index 99%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CallbackTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CallbackTest.php
index 337ea24..31df548
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CallbackTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CallbackTest.php
@@ -289,7 +289,7 @@ class CallbackTest extends TestOssClientBase
}
}
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CnameConfigTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CnameConfigTest.php
old mode 100644
new mode 100755
similarity index 97%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CnameConfigTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CnameConfigTest.php
index e3c1ce9..8f7529c
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CnameConfigTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CnameConfigTest.php
@@ -6,7 +6,7 @@ namespace OSS\Tests;
use OSS\Model\CnameConfig;
use OSS\Core\OssException;
-class CnameConfigTest extends \PHPUnit_Framework_TestCase
+class CnameConfigTest extends \PHPUnit\Framework\TestCase
{
private $xml1 = <<
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/Common.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/Common.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/Common.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/Common.php
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ContentTypeTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ContentTypeTest.php
old mode 100644
new mode 100755
similarity index 91%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ContentTypeTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ContentTypeTest.php
index 606c810..66b4057
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ContentTypeTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ContentTypeTest.php
@@ -4,7 +4,7 @@ namespace OSS\Tests;
require_once __DIR__ . '/Common.php';
-class ContentTypeTest extends \PHPUnit_Framework_TestCase
+class ContentTypeTest extends TestOssClientBase
{
private function runCmd($cmd)
{
@@ -17,15 +17,15 @@ class ContentTypeTest extends \PHPUnit_Framework_TestCase
private function getContentType($bucket, $object)
{
- $client = Common::getOssClient();
+ $client = $this->ossClient;
$headers = $client->getObjectMeta($bucket, $object);
return $headers['content-type'];
}
public function testByFileName()
{
- $client = Common::getOssClient();
- $bucket = Common::getBucketName();
+ $client = $this->ossClient;
+ $bucket = $this->bucket;
$file = '/tmp/x.html';
$object = 'test/x';
@@ -48,8 +48,8 @@ class ContentTypeTest extends \PHPUnit_Framework_TestCase
public function testByObjectKey()
{
- $client = Common::getOssClient();
- $bucket = Common::getBucketName();
+ $client = $this->ossClient;
+ $bucket = $this->bucket;
$object = "test/x.txt";
$client->putObject($bucket, $object, "hello world");
@@ -96,8 +96,8 @@ class ContentTypeTest extends \PHPUnit_Framework_TestCase
public function testByUser()
{
- $client = Common::getOssClient();
- $bucket = Common::getBucketName();
+ $client = $this->ossClient;
+ $bucket = $this->bucket;
$object = "test/x.txt";
$client->putObject($bucket, $object, "hello world", array(
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CopyObjectResult.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CopyObjectResult.php
old mode 100644
new mode 100755
similarity index 92%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CopyObjectResult.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CopyObjectResult.php
index 171d4c8..7d1b0fb
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CopyObjectResult.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CopyObjectResult.php
@@ -6,7 +6,7 @@ use OSS\Core\OssException;
use OSS\Http\ResponseCore;
use OSS\Result\CopyObjectResult;
-class CopyObjectResultTest extends \PHPUnit_Framework_TestCase
+class CopyObjectResultTest extends \PHPUnit\Framework\TestCase
{
private $body = <<
@@ -45,7 +45,7 @@ BBBB;
new CopyObjectResult($response);
$this->assertFalse(true);
} catch (OssException $e) {
-
+ $this->assertFalse(false);
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CorsConfigTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CorsConfigTest.php
old mode 100644
new mode 100755
similarity index 98%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CorsConfigTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CorsConfigTest.php
index ddc4d3a..3329b1a
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/CorsConfigTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/CorsConfigTest.php
@@ -7,7 +7,7 @@ use OSS\Model\CorsConfig;
use OSS\Model\CorsRule;
use OSS\Core\OssException;
-class CorsConfigTest extends \PHPUnit_Framework_TestCase
+class CorsConfigTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/DeleteObjectVersionsResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/DeleteObjectVersionsResultTest.php
new file mode 100755
index 0000000..890b1a5
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/DeleteObjectVersionsResultTest.php
@@ -0,0 +1,187 @@
+
+
+
+ demo.jpg
+ CAEQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk****
+ true
+ 111111
+
+
+ BBBB;
+
+ private $validXml1 = <<
+
+
+ multipart.data
+ CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4****
+
+
+ BBBB;
+
+ private $validXml2 = <<
+
+
+ multipart.data
+ true
+ CAEQMhiBgIDXiaaB0BYiIGQzYmRkZGUxMTM1ZDRjOTZhNjk4YjRjMTAyZjhl****
+
+
+ test.jpg
+ true
+ CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy****
+
+
+ BBBB;
+
+ private $validXml3 = <<
+
+
+ multipart.data
+
+
+ test.jpg
+
+
+ demo.jpg
+
+
+ BBBB;
+
+ private $validXml4 = <<
+
+ url
+
+ multipart%2F.data
+
+
+ test%2F.jpg
+
+
+ demo%2F.jpg
+
+
+ BBBB;
+
+ private $invalidXml = <<
+
+
+ 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));
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ExistResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ExistResultTest.php
old mode 100644
new mode 100755
similarity index 90%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ExistResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ExistResultTest.php
index e1b4e81..f9c552e
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ExistResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ExistResultTest.php
@@ -7,7 +7,7 @@ use OSS\Result\ExistResult;
use OSS\Http\ResponseCore;
use OSS\Core\OssException;
-class ExistResultTest extends \PHPUnit_Framework_TestCase
+class ExistResultTest extends \PHPUnit\Framework\TestCase
{
public function testParseValid200()
{
@@ -32,7 +32,7 @@ class ExistResultTest extends \PHPUnit_Framework_TestCase
new ExistResult($response);
$this->assertTrue(false);
} catch (OssException $e) {
-
+ $this->assertTrue(true);
}
}
}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketEncryptionResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketEncryptionResultTest.php
new file mode 100755
index 0000000..6f0e0d2
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketEncryptionResultTest.php
@@ -0,0 +1,95 @@
+
+
+
+ AES256
+
+
+
+ BBBB;
+
+ private $validXml1 = <<
+
+
+ KMS
+ kms-id
+
+
+ BBBB;
+
+ private $validXml2 = <<
+
+
+ KMS
+
+
+ BBBB;
+
+ private $invalidXml = <<
+
+
+ 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());
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php
new file mode 100755
index 0000000..2de08be
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php
@@ -0,0 +1,66 @@
+
+
+ Requester
+
+ BBBB;
+
+ private $validXml2 = <<
+
+ BucketOwner
+
+ BBBB;
+
+ private $invalidXml = <<
+
+
+ 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);
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketStatResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketStatResultTest.php
new file mode 100755
index 0000000..967e65d
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketStatResultTest.php
@@ -0,0 +1,59 @@
+
+
+ 100
+ 200
+ 10
+
+ BBBB;
+
+ private $invalidXml = <<
+
+
+ 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());
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketTagsResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketTagsResultTest.php
new file mode 100755
index 0000000..f4b2a88
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketTagsResultTest.php
@@ -0,0 +1,77 @@
+
+
+
+
+ testa
+ value1-test
+
+
+ testb
+ value2-test
+
+
+
+ BBBB;
+
+ private $invalidXml = <<
+
+
+ BBBB;
+
+ private $invalidXml2 = <<
+
+
+
+
+ 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()));
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketWormResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketWormResultTest.php
new file mode 100755
index 0000000..4d5d912
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetBucketWormResultTest.php
@@ -0,0 +1,84 @@
+
+
+ ID1
+ Locked
+ 1
+ 2018-08-14T15:50:32
+
+ BBBB;
+
+ private $validXml2 = <<
+
+ ID2
+ InProgress
+ 10
+ 2018-09-14T15:50:32
+
+ BBBB;
+
+ private $invalidXml = <<
+
+
+ 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());
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetCorsResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetCorsResultTest.php
old mode 100644
new mode 100755
similarity index 92%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetCorsResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetCorsResultTest.php
index a3281c8..76d87dc
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetCorsResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetCorsResultTest.php
@@ -7,7 +7,7 @@ use OSS\Core\OssException;
use OSS\Result\GetCorsResult;
use OSS\Http\ResponseCore;
-class GetCorsResultTest extends \PHPUnit_Framework_TestCase
+class GetCorsResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
@@ -58,10 +58,10 @@ BBBB;
{
$response = new ResponseCore(array(), $this->validXml, 300);
try {
- new GetCorsResult($response);
+ $result = new GetCorsResult($response);
$this->assertTrue(false);
} catch (OssException $e) {
-
+ $this->assertTrue(true);
}
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetLifecycleResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetLifecycleResultTest.php
old mode 100644
new mode 100755
similarity index 90%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetLifecycleResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetLifecycleResultTest.php
index 92ae208..e6d9a72
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetLifecycleResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetLifecycleResultTest.php
@@ -8,7 +8,7 @@ use OSS\Core\OssException;
use OSS\Model\LifecycleConfig;
use OSS\Result\GetLifecycleResult;
-class GetLifecycleResultTest extends \PHPUnit_Framework_TestCase
+class GetLifecycleResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
@@ -49,10 +49,10 @@ BBBB;
{
$response = new ResponseCore(array(), $this->validXml, 300);
try {
- new GetLifecycleResult($response);
+ $result = new GetLifecycleResult($response);
$this->assertTrue(false);
} catch (OssException $e) {
-
+ $this->assertTrue(true);
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetLoggingResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetLoggingResultTest.php
old mode 100644
new mode 100755
similarity index 89%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetLoggingResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetLoggingResultTest.php
index 6195014..35f7436
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetLoggingResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetLoggingResultTest.php
@@ -8,7 +8,7 @@ use OSS\Http\ResponseCore;
use OSS\Core\OssException;
-class GetLoggingResultTest extends \PHPUnit_Framework_TestCase
+class GetLoggingResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
@@ -42,10 +42,10 @@ BBBB;
{
$response = new ResponseCore(array(), $this->validXml, 300);
try {
- new GetLoggingResult($response);
+ $result = new GetLoggingResult($response);
$this->assertTrue(false);
} catch (OssException $e) {
-
+ $this->assertTrue(true);
}
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetRefererResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetRefererResultTest.php
old mode 100644
new mode 100755
similarity index 89%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetRefererResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetRefererResultTest.php
index 072aa43..774aae9
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetRefererResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetRefererResultTest.php
@@ -7,7 +7,7 @@ use OSS\Http\ResponseCore;
use OSS\Core\OssException;
-class GetRefererResultTest extends \PHPUnit_Framework_TestCase
+class GetRefererResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
@@ -42,10 +42,10 @@ BBBB;
{
$response = new ResponseCore(array(), $this->validXml, 300);
try {
- new GetRefererResult($response);
+ $result = new GetRefererResult($response);
$this->assertTrue(false);
} catch (OssException $e) {
-
+ $this->assertTrue(true);
}
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetWebsiteResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetWebsiteResultTest.php
old mode 100644
new mode 100755
similarity index 88%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetWebsiteResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetWebsiteResultTest.php
index 70e1559..d853306
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/GetWebsiteResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/GetWebsiteResultTest.php
@@ -7,7 +7,7 @@ use OSS\Result\GetWebsiteResult;
use OSS\Http\ResponseCore;
use OSS\Core\OssException;
-class GetWebsiteResultTest extends \PHPUnit_Framework_TestCase
+class GetWebsiteResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
@@ -41,10 +41,10 @@ BBBB;
{
$response = new ResponseCore(array(), $this->validXml, 300);
try {
- new GetWebsiteResult($response);
+ $result = new GetWebsiteResult($response);
$this->assertTrue(false);
} catch (OssException $e) {
-
+ $this->assertTrue(true);
}
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/HeaderResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/HeaderResultTest.php
old mode 100644
new mode 100755
similarity index 89%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/HeaderResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/HeaderResultTest.php
index dae4975..9354422
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/HeaderResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/HeaderResultTest.php
@@ -9,7 +9,7 @@ use OSS\Http\ResponseCore;
* Class HeaderResultTest
* @package OSS\Tests
*/
-class HeaderResultTest extends \PHPUnit_Framework_TestCase
+class HeaderResultTest extends \PHPUnit\Framework\TestCase
{
public function testGetHeader()
{
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/HttpTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/HttpTest.php
old mode 100644
new mode 100755
similarity index 96%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/HttpTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/HttpTest.php
index a59dfcd..989644c
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/HttpTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/HttpTest.php
@@ -7,7 +7,7 @@ use OSS\Http\ResponseCore;
use OSS\Http\RequestCore_Exception;
use Symfony\Component\Config\Definition\Exception\Exception;
-class HttpTest extends \PHPUnit_Framework_TestCase
+class HttpTest extends \PHPUnit\Framework\TestCase
{
public function testResponseCore()
@@ -33,7 +33,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase
$httpResponse = $httpCore->send_request();
$this->assertTrue(false);
} catch (RequestCore_Exception $e) {
-
+ $this->assertTrue(true);
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/InitiateMultipartUploadResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/InitiateMultipartUploadResultTest.php
old mode 100644
new mode 100755
similarity index 91%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/InitiateMultipartUploadResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/InitiateMultipartUploadResultTest.php
index 9f6c7a5..76b10a6
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/InitiateMultipartUploadResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/InitiateMultipartUploadResultTest.php
@@ -7,7 +7,7 @@ use OSS\Core\OssException;
use OSS\Result\InitiateMultipartUploadResult;
use OSS\Http\ResponseCore;
-class InitiateMultipartUploadResultTest extends \PHPUnit_Framework_TestCase
+class InitiateMultipartUploadResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
@@ -41,7 +41,7 @@ BBBB;
$result = new InitiateMultipartUploadResult($response);
$this->assertTrue(false);
} catch (OssException $e) {
-
+ $this->assertTrue(true);
}
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/LifecycleConfigTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/LifecycleConfigTest.php
old mode 100644
new mode 100755
similarity index 98%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/LifecycleConfigTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/LifecycleConfigTest.php
index 7bd0331..063e436
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/LifecycleConfigTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/LifecycleConfigTest.php
@@ -7,7 +7,7 @@ use OSS\Model\LifecycleAction;
use OSS\Model\LifecycleConfig;
use OSS\Model\LifecycleRule;
-class LifecycleConfigTest extends \PHPUnit_Framework_TestCase
+class LifecycleConfigTest extends \PHPUnit\Framework\TestCase
{
private $validLifecycle = <<
+
+
+ ut_test_put_bucket
+ ut_test_put_bucket
+
+
+
+ oss-cn-hangzhou-a
+ xz02tphky6fjfiuc0
+ 2014-05-15T11:18:32.000Z
+
+
+ oss-cn-hangzhou-a
+ xz02tphky6fjfiuc1
+ 2014-05-15T11:18:32.000Z
+
+
+
+BBBB;
+
+ private $nullXml = <<
+
+
+ ut_test_put_bucket
+ ut_test_put_bucket
+
+
+
+
+BBBB;
+
+ public function testParseValidXml()
+ {
+ $response = new ResponseCore(array(), $this->validXml, 200);
+ $result = new ListBucketsResult($response);
+ $this->assertTrue($result->isOK());
+ $this->assertNotNull($result->getData());
+ $this->assertNotNull($result->getRawResponse());
+ $bucketListInfo = $result->getData();
+ $this->assertEquals(2, count($bucketListInfo->getBucketList()));
+ }
+
+ public function testParseNullXml()
+ {
+ $response = new ResponseCore(array(), $this->nullXml, 200);
+ $result = new ListBucketsResult($response);
+ $this->assertTrue($result->isOK());
+ $this->assertNotNull($result->getData());
+ $this->assertNotNull($result->getRawResponse());
+ $bucketListInfo = $result->getData();
+ $this->assertEquals(0, count($bucketListInfo->getBucketList()));
+ }
+
+ public function test403()
+ {
+ $errorHeader = array(
+ 'x-oss-request-id' => '1a2b-3c4d'
+ );
+
+ $errorBody = <<< BBBB
+
+
+ NoSuchBucket
+ The specified bucket does not exist.
+ 566B870D207FB3044302EB0A
+ hello.oss-test.aliyun-inc.com
+ hello
+
+ BBBB;
+ $response = new ResponseCore($errorHeader, $errorBody, 403);
+ try {
+ new ListBucketsResult($response);
+ } catch (OssException $e) {
+ $this->assertEquals(
+ $e->getMessage(),
+ 'NoSuchBucket: The specified bucket does not exist. RequestId: 1a2b-3c4d');
+ $this->assertEquals($e->getHTTPStatus(), '403');
+ $this->assertEquals($e->getRequestId(), '1a2b-3c4d');
+ $this->assertEquals($e->getErrorCode(), 'NoSuchBucket');
+ $this->assertEquals($e->getErrorMessage(), 'The specified bucket does not exist.');
+ $this->assertEquals($e->getDetails(), $errorBody);
+ }
+ }
+
+ public function testParseXml2()
+ {
+ $xml = <<
+
+
+ ut_test_put_bucket
+ ut_test_put_bucket
+
+
+
+ 2015-12-17T18:12:43.000Z
+ oss-cn-shanghai.aliyuncs.com
+ oss-cn-shanghai-internal.aliyuncs.com
+ oss-cn-shanghai
+ app-base-oss
+ cn-shanghai
+ Standard
+
+
+ 2014-12-25T11:21:04.000Z
+ oss-cn-hangzhou.aliyuncs.com
+ oss-cn-hangzhou-internal.aliyuncs.com
+ oss-cn-hangzhou
+ atestleo23
+ cn-hangzhou
+ IA
+
+
+ 2014-12-25T11:21:04.000Z
+ oss-cn-hangzhou
+ atestleo23
+
+
+
+ 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());
+
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ListMultipartUploadResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ListMultipartUploadResultTest.php
old mode 100644
new mode 100755
similarity index 98%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ListMultipartUploadResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ListMultipartUploadResultTest.php
index 5c757d3..88bd0a7
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ListMultipartUploadResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ListMultipartUploadResultTest.php
@@ -9,7 +9,7 @@ use OSS\Http\ResponseCore;
* Class ListMultipartUploadResultTest
* @package OSS\Tests
*/
-class ListMultipartUploadResultTest extends \PHPUnit_Framework_TestCase
+class ListMultipartUploadResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ListObjectVersionsResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ListObjectVersionsResultTest.php
new file mode 100755
index 0000000..8ddbdaa
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ListObjectVersionsResultTest.php
@@ -0,0 +1,215 @@
+
+
+ oss-example
+
+ example
+ CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****
+ 100
+
+ false
+
+ example
+ CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****
+ false
+ 2019-04-09T07:27:28.000Z
+
+ 1234512528586****
+ 12345125285864390
+
+
+
+ example
+ CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****
+ false
+ 2019-04-09T07:27:28.000Z
+ "250F8A0AE989679A22926A875F0A2****"
+ Normal
+ 93731
+ Standard
+
+ 1234512528586****
+ 12345125285864390
+
+
+
+ pic.jpg
+ CAEQMxiBgMCZov2D0BYiIDY4MDllOTc2YmY5MjQxMzdiOGI3OTlhNTU0ODIx****
+ true
+ 2019-04-09T07:27:28.000Z
+ "3663F7B0B9D3153F884C821E7CF4****"
+ Normal
+ 574768
+ IA
+
+ 1234512528586****
+ 12345125285864390
+
+
+
+ BBBB;
+
+ private $validXml1 = <<
+
+ oss-example
+
+ example
+ CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****
+ 100
+
+ false
+
+ example
+ CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****
+ true
+ 2019-04-09T07:27:28.000Z
+
+ 1234512528586****
+ 12345125285864390
+
+
+
+ example-1
+ CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****
+ 2019-04-09T07:27:28.000Z
+
+ 1234512528586****
+ 12345125285864390
+
+
+
+ example-2
+ CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****
+ 2019-04-09T07:27:28.000Z
+ "250F8A0AE989679A22926A875F0A2****"
+ Normal
+ 93731
+ Standard
+
+ 1234512528586****
+ 12345125285864390
+
+
+
+ BBBB;
+
+ private $invalidXml = <<
+
+
+ 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();
+ $this->assertTrue(true);
+ }
+
+ public function testParseInvalidXml()
+ {
+ $response = new ResponseCore(array(), $this->invalidXml, 200);
+ $result = new ListObjectVersionsResult($response);
+ $stat = $result->getData();
+ $this->assertTrue(true);
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ListObjectsResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ListObjectsResultTest.php
old mode 100644
new mode 100755
similarity index 98%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ListObjectsResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ListObjectsResultTest.php
index 85f262c..c977ce7
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ListObjectsResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ListObjectsResultTest.php
@@ -6,7 +6,7 @@ namespace OSS\Tests;
use OSS\Result\ListObjectsResult;
use OSS\Http\ResponseCore;
-class ListObjectsResultTest extends \PHPUnit_Framework_TestCase
+class ListObjectsResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml1 = <<
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/LiveChannelXmlTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/LiveChannelXmlTest.php
old mode 100644
new mode 100755
similarity index 89%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/LiveChannelXmlTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/LiveChannelXmlTest.php
index cc3e219..b69ef7c
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/LiveChannelXmlTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/LiveChannelXmlTest.php
@@ -4,13 +4,15 @@ namespace OSS\Tests;
require_once __DIR__ . '/Common.php';
+use OSS\Core\OssException;
use OSS\Model\LiveChannelInfo;
use OSS\Model\LiveChannelListInfo;
use OSS\Model\LiveChannelConfig;
use OSS\Model\GetLiveChannelStatus;
use OSS\Model\GetLiveChannelHistory;
+use OSS\Model\LiveChannelHistory;
-class LiveChannelXmlTest extends \PHPUnit_Framework_TestCase
+class LiveChannelXmlTest extends \PHPUnit\Framework\TestCase
{
private $config = <<
@@ -139,7 +141,7 @@ BBBB;
}
- public function testLiveChannelHistory()
+ public function testGetLiveChannelHistory()
{
$history = new GetLiveChannelHistory();
$history->parseFromXml($this->history);
@@ -246,4 +248,30 @@ BBBB;
$this->assertEquals('http://bucket.oss-cn-hangzhou.aliyuncs.com/2/播放列表.m3u8', $plays[0]);
}
+ public function testLiveChannelHistory()
+ {
+ $xml = "2013-11-24T14:25:31.000Z2013-11-24T15:25:31.000Z10.101.194.148:56861";
+ $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);
+ }
+ }
+ }
+
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/LoggingConfigTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/LoggingConfigTest.php
old mode 100644
new mode 100755
similarity index 95%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/LoggingConfigTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/LoggingConfigTest.php
index 01496bb..05336c8
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/LoggingConfigTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/LoggingConfigTest.php
@@ -4,7 +4,7 @@ namespace OSS\Tests;
use OSS\Model\LoggingConfig;
-class LoggingConfigTest extends \PHPUnit_Framework_TestCase
+class LoggingConfigTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/MimeTypesTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/MimeTypesTest.php
old mode 100644
new mode 100755
similarity index 77%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/MimeTypesTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/MimeTypesTest.php
index 0697409..1403d09
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/MimeTypesTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/MimeTypesTest.php
@@ -4,7 +4,7 @@ namespace OSS\Tests;
use OSS\Core\MimeTypes;
-class MimeTypesTest extends \PHPUnit_Framework_TestCase
+class MimeTypesTest extends \PHPUnit\Framework\TestCase
{
public function testGetMimeType()
{
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ObjectAclTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ObjectAclTest.php
old mode 100644
new mode 100755
similarity index 82%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ObjectAclTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ObjectAclTest.php
index d397288..9260a6a
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/ObjectAclTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/ObjectAclTest.php
@@ -4,12 +4,12 @@ namespace OSS\Tests;
require_once __DIR__ . '/Common.php';
-class ObjectAclTest extends \PHPUnit_Framework_TestCase
+class ObjectAclTest extends TestOssClientBase
{
public function testGetSet()
{
- $client = Common::getOssClient();
- $bucket = Common::getBucketName();
+ $client = $this->ossClient;
+ $bucket = $this->bucket;
$object = 'test/object-acl';
$client->deleteObject($bucket, $object);
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketCorsTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketCorsTest.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketCorsTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketCorsTest.php
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketEncryptionTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketEncryptionTest.php
new file mode 100755
index 0000000..42c51b2
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketEncryptionTest.php
@@ -0,0 +1,63 @@
+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());
+ }
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketInfoTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketInfoTest.php
new file mode 100755
index 0000000..759e536
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketInfoTest.php
@@ -0,0 +1,20 @@
+ossClient->getBucketInfo($this->bucket);
+ $this->assertEquals($this->bucket, $info->getName());
+ $this->assertEquals("Standard", $info->getStorageClass());
+ } catch (OssException $e) {
+ $this->assertTrue(false);
+ }
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketLifecycleTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketLifecycleTest.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketLifecycleTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketLifecycleTest.php
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketLoggingTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketLoggingTest.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketLoggingTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketLoggingTest.php
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketPolicyTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketPolicyTest.php
new file mode 100755
index 0000000..4f0c5ee
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketPolicyTest.php
@@ -0,0 +1,47 @@
+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);
+ }
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketRefererTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketRefererTest.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketRefererTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketRefererTest.php
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php
new file mode 100755
index 0000000..9a4b412
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php
@@ -0,0 +1,51 @@
+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);
+ }
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketStatTestTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketStatTestTest.php
new file mode 100755
index 0000000..7f847d8
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketStatTestTest.php
@@ -0,0 +1,34 @@
+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);
+ }
+ }
+
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketTagsTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketTagsTest.php
new file mode 100755
index 0000000..bafa64b
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketTagsTest.php
@@ -0,0 +1,76 @@
+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);
+ }
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketTest.php
old mode 100644
new mode 100755
similarity index 79%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketTest.php
index d0a2a22..6bac445
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketTest.php
@@ -10,6 +10,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
class OssClientBucketTest extends TestOssClientBase
{
+ private $standardBucket;
private $iaBucket;
private $archiveBucket;
@@ -80,12 +81,31 @@ class OssClientBucketTest extends TestOssClientBase
$this->assertEquals($result, 'testcontent');
}
- public function setUp()
+ 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);
+ }
+ }
+ }
+
+ protected function setUp(): void
{
parent::setUp();
$this->iaBucket = 'ia-' . $this->bucket;
$this->archiveBucket = 'archive-' . $this->bucket;
+ $this->standardBucket = 'standard-' . $this->bucket;
+
$options = array(
OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_IA
);
@@ -97,9 +117,15 @@ class OssClientBucketTest extends TestOssClientBase
);
$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()
+ protected function tearDown(): void
{
parent::tearDown();
@@ -109,5 +135,6 @@ class OssClientBucketTest extends TestOssClientBase
$this->ossClient->deleteObject($this->archiveBucket, $object);
$this->ossClient->deleteBucket($this->iaBucket);
$this->ossClient->deleteBucket($this->archiveBucket);
+ $this->ossClient->deleteBucket($this->standardBucket);
}
}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketVersioningTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketVersioningTest.php
new file mode 100755
index 0000000..d9aa5a4
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketVersioningTest.php
@@ -0,0 +1,40 @@
+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);
+ }
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketWebsiteTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketWebsiteTest.php
old mode 100644
new mode 100755
similarity index 100%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientBucketWebsiteTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketWebsiteTest.php
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketWormTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketWormTest.php
new file mode 100755
index 0000000..85df417
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientBucketWormTest.php
@@ -0,0 +1,36 @@
+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);
+ }
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientImageTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientImageTest.php
old mode 100644
new mode 100755
similarity index 55%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientImageTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientImageTest.php
index df8bd6c..6def9f9
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientImageTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientImageTest.php
@@ -6,7 +6,7 @@ require_once __DIR__ . '/Common.php';
use OSS\OssClient;
-class OssClinetImageTest extends \PHPUnit_Framework_TestCase
+class OssClinetImageTest extends TestOssClientBase
{
private $bucketName;
private $client;
@@ -14,23 +14,24 @@ class OssClinetImageTest extends \PHPUnit_Framework_TestCase
private $object;
private $download_file;
- public function setUp()
+ protected function setUp(): void
{
- $this->client = Common::getOssClient();
- $this->bucketName = 'php-sdk-test-bucket-image-' . strval(rand(0, 10000));
- $this->client->createBucket($this->bucketName);
- Common::waitMetaSync();
+ parent::setUp();
+
+ $this->client = $this->ossClient;
+ $this->bucketName = $this->bucket;
$this->local_file = "example.jpg";
$this->object = "oss-example.jpg";
$this->download_file = "image.jpg";
+ Common::waitMetaSync();
$this->client->uploadFile($this->bucketName, $this->object, $this->local_file);
}
- public function tearDown()
+ protected function tearDown(): void
{
- $this->client->deleteObject($this->bucketName, $this->object);
- $this->client->deleteBucket($this->bucketName);
+ parent::tearDown();
+ unlink($this->download_file);
}
public function testImageResize()
@@ -89,6 +90,47 @@ class OssClinetImageTest extends \PHPUnit_Framework_TestCase
$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)
{
$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($type === 'jpg' ? 2 : 3, $array[2]);//2 <=> jpg
}
+
+ private function base64url_encode($data)
+ {
+ return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
+ }
}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientListObjectsTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientListObjectsTest.php
new file mode 100755
index 0000000..8ee47a2
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientListObjectsTest.php
@@ -0,0 +1,184 @@
+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());
+ }
+
+ protected function setUp(): void
+ {
+ 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");
+ }
+
+ }
+
+ protected function tearDown(): void
+ {
+ parent::tearDown();
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientMultipartUploadTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientMultipartUploadTest.php
old mode 100644
new mode 100755
similarity index 72%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientMultipartUploadTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientMultipartUploadTest.php
index a95f412..0e86162
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientMultipartUploadTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientMultipartUploadTest.php
@@ -108,6 +108,54 @@ class OssClientMultipartUploadTest extends TestOssClientBase
$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), 'ossClient->generateMultiuploadParts($upload_filesize, $part_size);
$response_upload_part = array();
$upload_position = 0;
@@ -159,7 +207,7 @@ class OssClientMultipartUploadTest extends TestOssClientBase
}
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);
} catch (OssException $e) {
$this->assertTrue(false);
@@ -184,7 +232,7 @@ class OssClientMultipartUploadTest extends TestOssClientBase
$numOfMultipartUpload2 = 0;
try {
- $listMultipartUploadInfo = $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, $options);
+ $listMultipartUploadInfo = $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, array('max-uploads' => 1000));
$this->assertNotNull($listMultipartUploadInfo);
$numOfMultipartUpload2 = count($listMultipartUploadInfo->getUploads());
} catch (OssException $e) {
@@ -209,7 +257,7 @@ class OssClientMultipartUploadTest extends TestOssClientBase
*/
$part_size = 10 * 1024 * 1024;
$upload_file = __FILE__;
- $upload_filesize = filesize($upload_file);
+ $upload_filesize = sprintf('%u',filesize($upload_file));
$pieces = $this->ossClient->generateMultiuploadParts($upload_filesize, $part_size);
$response_upload_part = array();
$upload_position = 0;
@@ -282,6 +330,7 @@ class OssClientMultipartUploadTest extends TestOssClientBase
try {
$this->ossClient->multiuploadFile($this->bucket, $object, $file, $options);
+ $this->assertFalse(false);
} catch (OssException $e) {
$this->assertFalse(true);
}
@@ -295,11 +344,59 @@ class OssClientMultipartUploadTest extends TestOssClientBase
try {
$this->ossClient->multiuploadFile($this->bucket, $object, $file, $options);
+ $this->assertFalse(false);
} catch (OssException $e) {
$this->assertFalse(true);
}
}
+ 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), '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), 'assertFalse(true);
+ }
+ }
+
+ public function testPutObjectByMultipartUploadWithException()
+ {
+ $object = "mpu/multipart-test-exception.txt";
+ $file = "";
+
+ try {
+ $this->ossClient->multiuploadFile($this->bucket, $object, $file);
+ $this->assertTrue(false);
+ } catch (OssException $e) {
+ $this->assertTrue(true);
+ if (strpos($e, "parameter invalid, file is empty") == false)
+ {
+ $this->assertTrue(true);
+ }
+ }
+ }
+
public function testListMultipartUploads()
{
$options = null;
@@ -310,4 +407,20 @@ class OssClientMultipartUploadTest extends TestOssClientBase
$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);
+ }
+ }
+ }
}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php
new file mode 100755
index 0000000..6625188
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php
@@ -0,0 +1,472 @@
+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 = sprintf('%u',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);
+ $this->assertTrue(true);
+ } 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);
+ }
+
+ protected function setUp(): void
+ {
+ 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");
+ }
+
+ protected function tearDown(): void
+ {
+ parent::tearDown();
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectTaggingTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectTaggingTest.php
new file mode 100755
index 0000000..401d1b7
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectTaggingTest.php
@@ -0,0 +1,160 @@
+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);
+ }
+
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientObjectTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectTest.php
old mode 100644
new mode 100755
similarity index 73%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientObjectTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectTest.php
index 2f1201b..bb61018
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientObjectTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectTest.php
@@ -88,7 +88,6 @@ class OssClientObjectTest extends TestOssClientBase
'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',
@@ -328,12 +327,18 @@ class OssClientObjectTest extends TestOssClientBase
$this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object2));
$result = $this->ossClient->deleteObjects($this->bucket, $list);
- $this->assertEquals($list[1], $result[0]);
- $this->assertEquals($list[0], $result[1]);
+ $this->assertEquals($list[0], $result[0]);
+ $this->assertEquals($list[1], $result[1]);
$result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => 'true'));
$this->assertEquals(array(), $result);
$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) {
$this->assertFalse(true);
}
@@ -352,8 +357,8 @@ class OssClientObjectTest extends TestOssClientBase
$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);
- $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + 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]));
} catch (OssException $e) {
$this->assertFalse(true);
}
@@ -378,14 +383,24 @@ class OssClientObjectTest extends TestOssClientBase
$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
*/
try {
$position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0);
- $this->assertEquals($position, filesize(__FILE__));
+ $this->assertEquals($position, sprintf('%u',filesize(__FILE__)));
$position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position);
- $this->assertEquals($position, filesize(__FILE__) * 2);
+ $this->assertEquals($position, sprintf('%u',filesize(__FILE__)) * 2);
} catch (OssException $e) {
$this->assertFalse(true);
}
@@ -553,9 +568,9 @@ class OssClientObjectTest extends TestOssClientBase
*/
try {
$position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0, $options);
- $this->assertEquals($position, filesize(__FILE__));
+ $this->assertEquals($position, sprintf('%u',filesize(__FILE__)));
$position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position, $options);
- $this->assertEquals($position, filesize(__FILE__) * 2);
+ $this->assertEquals($position, sprintf('%u',filesize(__FILE__)) * 2);
} catch (OssException $e) {
$this->assertFalse(true);
}
@@ -590,7 +605,175 @@ class OssClientObjectTest extends TestOssClientBase
}
}
- public function setUp()
+ 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 testObjectKeyWithQuestionMark()
+ {
+ /**
+ * Upload the local variable to bucket
+ */
+ $object = "oss-php-sdk-test/??/upload-test-object-name???123??123??.txt";
+ $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-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);
+ }
+
+ try {
+ $this->ossClient->putObject($this->bucket, $object, $content, $options);
+ } catch (OssException $e) {
+ $this->assertFalse(true);
+ }
+
+ /**
+ * GetObject to the local variable and check for match
+ */
+ try {
+ $content = $this->ossClient->getObject($this->bucket, $object);
+ $this->assertEquals($content, file_get_contents(__FILE__));
+ } catch (OssException $e) {
+ $this->assertFalse(true);
+ }
+
+ /**
+ * GetObject first five bytes
+ */
+ try {
+ $options = array(OssClient::OSS_RANGE => '0-4');
+ $content = $this->ossClient->getObject($this->bucket, $object, $options);
+ $this->assertEquals($content, 'assertFalse(true);
+ }
+
+
+ /**
+ * Upload the local file to object
+ */
+ try {
+ $this->ossClient->uploadFile($this->bucket, $object, __FILE__);
+ } catch (OssException $e) {
+ $this->assertFalse(true);
+ }
+
+ /**
+ * Download the file to the local variable and check for match.
+ */
+ try {
+ $content = $this->ossClient->getObject($this->bucket, $object);
+ $this->assertEquals($content, file_get_contents(__FILE__));
+ } catch (OssException $e) {
+ $this->assertFalse(true);
+ }
+
+ /**
+ * Copy object
+ */
+ $to_bucket = $this->bucket;
+ $to_object = $object . '.copy';
+ $options = array();
+ try {
+ $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options);
+ $this->assertFalse(empty($result));
+ $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0]));
+ $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1]));
+ } catch (OssException $e) {
+ $this->assertFalse(true);
+ var_dump($e->getMessage());
+
+ }
+
+ /**
+ * Check if the replication is the same
+ */
+ try {
+ $content = $this->ossClient->getObject($this->bucket, $to_object);
+ $this->assertEquals($content, file_get_contents(__FILE__));
+ } catch (OssException $e) {
+ $this->assertFalse(true);
+ }
+
+
+ try {
+ $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object));
+ $this->ossClient->deleteObject($this->bucket, $object);
+ $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object));
+ } catch (OssException $e) {
+ $this->assertFalse(true);
+ }
+ }
+
+ protected function setUp(): void
{
parent::setUp();
$this->ossClient->putObject($this->bucket, 'oss-php-sdk-test/upload-test-object-name.txt', file_get_contents(__FILE__));
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectVersioningTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectVersioningTest.php
new file mode 100755
index 0000000..66f204a
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientObjectVersioningTest.php
@@ -0,0 +1,610 @@
+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));
+ }
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+
+ $this->ossClient->putBucketVersioning($this->bucket, "Enabled");
+
+ }
+
+ protected function tearDown(): void
+ {
+ 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();
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientRestoreObjectTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientRestoreObjectTest.php
old mode 100644
new mode 100755
similarity index 52%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientRestoreObjectTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientRestoreObjectTest.php
index cc1412f..9aa0b9b
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientRestoreObjectTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientRestoreObjectTest.php
@@ -4,6 +4,7 @@ namespace OSS\Tests;
use OSS\Core\OssException;
use OSS\OssClient;
+use OSS\Model\RestoreConfig;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
@@ -63,7 +64,84 @@ class OssClientRestoreObjectTest extends TestOssClientBase
}
}
- public function setUp()
+ 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);
+ }
+
+
+ protected function setUp(): void
{
parent::setUp();
@@ -82,7 +160,7 @@ class OssClientRestoreObjectTest extends TestOssClientBase
$this->ossClient->createBucket($this->archiveBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options);
}
- public function tearDown()
+ protected function tearDown(): void
{
parent::tearDown();
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientSignatureTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientSignatureTest.php
old mode 100644
new mode 100755
similarity index 63%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientSignatureTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientSignatureTest.php
index 109121d..00cf89a
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientSignatureTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientSignatureTest.php
@@ -64,7 +64,7 @@ class OssClientSignatureTest extends TestOssClientBase
$request->set_method('PUT');
$request->add_header('Content-Type', 'txt');
$request->set_read_file($file);
- $request->set_read_stream_size(filesize($file));
+ $request->set_read_stream_size(sprintf('%u',filesize($file)));
$request->send_request();
$res = new ResponseCore($request->get_response_header(),
$request->get_response_body(), $request->get_response_code());
@@ -75,13 +75,69 @@ class OssClientSignatureTest extends TestOssClientBase
}
- public function tearDown()
+ public function testSignedUrlWithException()
+ {
+ $file = __FILE__;
+ $object = "a.file";
+ $timeout = 3600;
+ $options = array('Content-Type' => 'txt');
+ try {
+ $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "POST", $options);
+ $this->assertTrue(false);
+ } catch (OssException $e) {
+ $this->assertTrue(true);
+ if (strpos($e, "method is invalid") == false)
+ {
+ $this->assertTrue(false);
+ }
+ }
+ }
+
+ function testGetgenPreSignedUrlForGettingObject()
+ {
+ $object = "a.file";
+ $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__));
+ $expires = time() + 3600;
+ try {
+ $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires);
+ } 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(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);
+ }
+
+ protected function tearDown(): void
{
$this->ossClient->deleteObject($this->bucket, "a.file");
parent::tearDown();
}
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
/**
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientTest.php
old mode 100644
new mode 100755
similarity index 58%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientTest.php
index f92b346..b7c676f
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssClientTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssClientTest.php
@@ -6,7 +6,7 @@ use OSS\Core\OssException;
use OSS\OssClient;
-class OssClientTest extends \PHPUnit_Framework_TestCase
+class OssClientTest extends TestOssClientBase
{
public function testConstrunct()
{
@@ -60,6 +60,7 @@ class OssClientTest extends \PHPUnit_Framework_TestCase
{
try {
$ossClient = new OssClient('id', 'key', "123.123.123.1");
+ $this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
@@ -70,6 +71,15 @@ class OssClientTest extends \PHPUnit_Framework_TestCase
try {
$ossClient = new OssClient('id', 'key', "https://123.123.123.1");
$this->assertTrue($ossClient->isUseSSL());
+ $this->assertTrue(true);
+ } catch (OssException $e) {
+ $this->assertTrue(false);
+ }
+
+ try {
+ $ossClient = new OssClient('id', 'key', "https://123.123.123.1:3128");
+ $this->assertTrue($ossClient->isUseSSL());
+ $this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
@@ -80,6 +90,15 @@ class OssClientTest extends \PHPUnit_Framework_TestCase
try {
$ossClient = new OssClient('id', 'key', "http://123.123.123.1");
$this->assertFalse($ossClient->isUseSSL());
+ $this->assertTrue(true);
+ } catch (OssException $e) {
+ $this->assertTrue(false);
+ }
+
+ try {
+ $ossClient = new OssClient('id', 'key', "http://123.123.123.1:3128");
+ $this->assertFalse($ossClient->isUseSSL());
+ $this->assertTrue(true);
} catch (OssException $e) {
$this->assertTrue(false);
}
@@ -92,7 +111,7 @@ class OssClientTest extends \PHPUnit_Framework_TestCase
$ossClient->listBuckets();
$this->assertFalse(true);
} catch (OssException $e) {
-
+ $this->assertFalse(false);
}
}
@@ -104,36 +123,92 @@ class OssClientTest extends \PHPUnit_Framework_TestCase
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);
$ossClient->listBuckets();
+ $this->assertTrue(true);
} catch (OssException $e) {
$this->assertFalse(true);
}
}
+ public function testConstrunct10()
+ {
+ try {
+ $ossClient = new OssClient('id', 'key', "http://ABC-COM.TEST.123.cn", true);
+ $this->assertTrue(true);
+ } catch (OssException $e) {
+ $this->assertTrue(false);
+ }
+ }
+
+ public function testConstrunct11()
+ {
+ try {
+ $ossClient = new OssClient('id', 'key', "oss-test.com\\aliyuncs.com");
+ $this->assertFalse(true);
+ } catch (OssException $e) {
+ $this->assertEquals('endpoint is invalid:'."oss-test.com\\aliyuncs.com", $e->getMessage());
+ }
+ }
+
+ public function testConstrunct12()
+ {
+ try {
+ $ossClient = new OssClient('id', 'key', "192.168.1.0:abc123");
+ $this->assertFalse(true);
+ } catch (OssException $e) {
+ $this->assertEquals('endpoint is invalid:'."192.168.1.0:abc123", $e->getMessage());
+ }
+ }
+
public function testSupportPutEmptyObject()
{
try {
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
- $bucket = getenv('OSS_BUCKET');
+ $bucket = $this->bucket;
$ossClient = new OssClient($accessKeyId, $accessKeySecret , $endpoint, false);
$ossClient->putObject($bucket,'test_emptybody','');
} catch (OssException $e) {
$this->assertFalse(true);
}
- }
- public function testCreateObjectDir()
- {
+ //use invalid sts-token, should fail.
try {
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
- $bucket = getenv('OSS_BUCKET');
- $object='test-dir';
- $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);
- $ossClient->createObjectDir($bucket,$object);
+ $bucket = $this->bucket;
+ $ossClient = new OssClient($accessKeyId, $accessKeySecret , $endpoint, false, "invalid-sts-token");
+ $ossClient->putObject($bucket,'test_emptybody','');
+ $this->assertTrue(false);
} catch (OssException $e) {
+ $this->assertEquals('InvalidAccessKeyId', $e->getErrorCode());
+ }
+ }
+
+ public function testCreateObjectDir()
+ {
+ $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);
+
+ try {
+ $object='test-dir';
+ $ossClient->createObjectDir($bucket,$object);
+ $this->assertTrue(true);
+ } catch (OssException $e) {
+ $this->assertFalse(true);
+ }
+
+ try {
+ $object='0';
+ $ossClient->createObjectDir($bucket,$object);
+ $ossClient->putObject($bucket,$object, '');
+ $this->assertTrue(true);
+ } catch (OssException $e) {
+ var_dump($e);
$this->assertFalse(true);
}
}
@@ -147,6 +222,7 @@ class OssClientTest extends \PHPUnit_Framework_TestCase
$bucket = getenv('OSS_BUCKET');
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);
$ossClient->getBucketCors($bucket);
+ $this->assertTrue(true);
} catch (OssException $e) {
$this->assertFalse(true);
}
@@ -158,9 +234,10 @@ class OssClientTest extends \PHPUnit_Framework_TestCase
$accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' ';
$accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' ';
$endpoint = ' ' . getenv('OSS_ENDPOINT') . '/ ';
- $bucket = getenv('OSS_BUCKET');
+ $bucket = $this->bucket;
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);
$ossClient->getBucketCname($bucket);
+ $this->assertTrue(true);
} catch (OssException $e) {
$this->assertFalse(true);
}
@@ -213,4 +290,57 @@ class OssClientTest extends \PHPUnit_Framework_TestCase
$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);
+ }
+ }
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssExceptionTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssExceptionTest.php
old mode 100644
new mode 100755
similarity index 85%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssExceptionTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssExceptionTest.php
index 4a418d5..91de9bb
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssExceptionTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssExceptionTest.php
@@ -4,7 +4,7 @@ namespace OSS\Tests;
use OSS\Core\OssException;
-class OssExceptionTest extends \PHPUnit_Framework_TestCase
+class OssExceptionTest extends \PHPUnit\Framework\TestCase
{
public function testOSS_exception()
{
diff --git a/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssTrafficLimitTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssTrafficLimitTest.php
new file mode 100755
index 0000000..5aeb0ea
--- /dev/null
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssTrafficLimitTest.php
@@ -0,0 +1,96 @@
+ 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);
+ }
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssUtilTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssUtilTest.php
old mode 100644
new mode 100755
similarity index 79%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssUtilTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssUtilTest.php
index c565249..598a7cc
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/OssUtilTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/OssUtilTest.php
@@ -7,7 +7,7 @@ use OSS\Core\OssException;
use OSS\Core\OssUtil;
use OSS\OssClient;
-class OssUtilTest extends \PHPUnit_Framework_TestCase
+class OssUtilTest extends \PHPUnit\Framework\TestCase
{
public function testIsChinese()
{
@@ -147,21 +147,25 @@ BBBB;
$this->assertNotNull($list);
}
- public function testIsWin()
- {
- //$this->assertTrue(OssUtil::isWin());
- }
+ //public function testIsWin()
+ //{
+ // //$this->assertTrue(OssUtil::isWin());
+ //}
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, sprintf('%u',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, sprintf('%u',filesize(__FILE__)) + 1), "");
+
}
public function testGenerateFile()
{
$path = __DIR__ . DIRECTORY_SEPARATOR . "generatedFile.txt";
OssUtil::generateFile($path, 1024 * 1024);
- $this->assertEquals(filesize($path), 1024 * 1024);
+ $this->assertEquals(sprintf('%u',filesize($path)), 1024 * 1024);
unlink($path);
}
@@ -242,10 +246,55 @@ BBBB;
$str = OssUtil::getHostPortFromEndpoint('192.168.1.10:8080');
$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');
$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);
+ }
}
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/PutSetDeleteResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/PutSetDeleteResultTest.php
old mode 100644
new mode 100755
similarity index 91%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/PutSetDeleteResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/PutSetDeleteResultTest.php
index b298e44..202f173
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/PutSetDeleteResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/PutSetDeleteResultTest.php
@@ -6,7 +6,7 @@ use OSS\Core\OssException;
use OSS\Http\ResponseCore;
use OSS\Result\PutSetDeleteResult;
-class ResultTest extends \PHPUnit_Framework_TestCase
+class ResultTest extends \PHPUnit\Framework\TestCase
{
public function testNullResponse()
@@ -50,16 +50,16 @@ class ResultTest extends \PHPUnit_Framework_TestCase
new PutSetDeleteResult($response);
$this->assertFalse(true);
} catch (OssException $e) {
-
+ $this->assertFalse(false);
}
}
- public function setUp()
+ protected function setUp(): void
{
}
- public function tearDown()
+ protected function tearDown(): void
{
}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/RefererConfigTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/RefererConfigTest.php
old mode 100644
new mode 100755
similarity index 96%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/RefererConfigTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/RefererConfigTest.php
index 8360a24..5112da8
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/RefererConfigTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/RefererConfigTest.php
@@ -5,7 +5,7 @@ namespace OSS\Tests;
use OSS\Model\RefererConfig;
-class RefererConfigTest extends \PHPUnit_Framework_TestCase
+class RefererConfigTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<
+
+10
+
+BBBB;
+
+private $validXml_20 = <<
+
+20
+
+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));
+ }
+}
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/StorageCapacityTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/StorageCapacityTest.php
old mode 100644
new mode 100755
similarity index 86%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/StorageCapacityTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/StorageCapacityTest.php
index 4562da7..8d2a9df
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/StorageCapacityTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/StorageCapacityTest.php
@@ -6,7 +6,7 @@ use OSS\Model\StorageCapacityConfig;
use OSS\Result\GetStorageCapacityResult;
use OSS\Core\OssException;
-class StorageCapacityTest extends \PHPUnit_Framework_TestCase
+class StorageCapacityTest extends \PHPUnit\Framework\TestCase
{
private $inValidXml = <<assertTrue(false);
- } catch (OssException $e) {}
+ } catch (OssException $e) {
+ $this->assertTrue(true);
+ }
}
public function testParseEmptyXml()
@@ -38,7 +40,9 @@ BBBB;
try {
new GetStorageCapacityResult($response);
$this->assertTrue(false);
- } catch (OssException $e) {}
+ } catch (OssException $e) {
+ $this->assertTrue(true);
+ }
}
public function testParseValidXml()
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/SymlinkTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/SymlinkTest.php
old mode 100644
new mode 100755
similarity index 85%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/SymlinkTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/SymlinkTest.php
index 4a39dfa..c436391
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/SymlinkTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/SymlinkTest.php
@@ -13,7 +13,7 @@ class SymlinkTest extends TestOssClientBase
{
public function testPutSymlink()
{
- $bucket = getenv('OSS_BUCKET');
+ $bucket = $this->bucket;
$symlink = 'test-link';
$special_object = 'exist_object^$#!~';
$object = 'exist_object';
@@ -31,10 +31,13 @@ class SymlinkTest extends TestOssClientBase
public function testGetSymlink()
{
- $bucket = getenv('OSS_BUCKET');
+ $bucket = $this->bucket;
$symlink = 'test-link';
$object = 'exist_object^$#!~';
+ $this->ossClient ->putObject($bucket, $object, 'test_content');
+ $this->ossClient->putSymlink($bucket, $symlink, $object);
+
$result = $this->ossClient->getSymlink($bucket, $symlink);
$this->assertEquals($result[OssClient::OSS_SYMLINK_TARGET], $object);
$this->assertEquals('200', $result[OssClient::OSS_INFO][OssClient::OSS_HTTP_CODE]);
@@ -44,7 +47,7 @@ class SymlinkTest extends TestOssClientBase
public function testPutNullSymlink()
{
- $bucket = getenv('OSS_BUCKET');
+ $bucket = $this->bucket;
$symlink = 'null-link';
$object_not_exist = 'not_exist_object+$#!b不';
$this->ossClient->putSymlink($bucket, $symlink, $object_not_exist);
@@ -53,13 +56,13 @@ class SymlinkTest extends TestOssClientBase
$this->ossClient->getObject($bucket, $symlink);
$this->assertTrue(false);
}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()
{
- $bucket = getenv('OSS_BUCKET');
+ $bucket = $this->bucket;
$symlink = 'null-link-new';
try{
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/TestOssClientBase.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/TestOssClientBase.php
old mode 100644
new mode 100755
similarity index 82%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/TestOssClientBase.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/TestOssClientBase.php
index 4abd31f..b204871
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/TestOssClientBase.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/TestOssClientBase.php
@@ -6,7 +6,7 @@ use OSS\OssClient;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'Common.php';
-class TestOssClientBase extends \PHPUnit_Framework_TestCase
+class TestOssClientBase extends \PHPUnit\Framework\TestCase
{
/**
* @var OssClient
@@ -18,15 +18,15 @@ class TestOssClientBase extends \PHPUnit_Framework_TestCase
*/
protected $bucket;
- public function setUp()
+ protected function setUp(): void
{
- $this->bucket = Common::getBucketName() . rand(100000, 999999);
+ $this->bucket = Common::getBucketName() .'-'. time();
$this->ossClient = Common::getOssClient();
$this->ossClient->createBucket($this->bucket);
- Common::waitMetaSync();
+ Common::waitMetaSync();
}
- public function tearDown()
+ protected function tearDown(): void
{
if (!$this->ossClient->doesBucketExist($this->bucket)) {
return;
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/UploadPartResultTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/UploadPartResultTest.php
old mode 100644
new mode 100755
similarity index 93%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/UploadPartResultTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/UploadPartResultTest.php
index e4789ef..df4ad94
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/UploadPartResultTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/UploadPartResultTest.php
@@ -7,7 +7,7 @@ use OSS\Core\OssException;
use OSS\Result\UploadPartResult;
use OSS\Http\ResponseCore;
-class UploadPartResultTest extends \PHPUnit_Framework_TestCase
+class UploadPartResultTest extends \PHPUnit\Framework\TestCase
{
private $validHeader = array('etag' => '7265F4D211B56873A381D321F586E4A9');
private $invalidHeader = array();
diff --git a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/WebsiteConfigTest.php b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/WebsiteConfigTest.php
old mode 100644
new mode 100755
similarity index 96%
rename from aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/WebsiteConfigTest.php
rename to aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/WebsiteConfigTest.php
index 2ec0fcb..d04b42c
--- a/aliyun-oss-php-sdk-2.3.1/tests/OSS/Tests/WebsiteConfigTest.php
+++ b/aliyun-oss-php-sdk-2.4.3/tests/OSS/Tests/WebsiteConfigTest.php
@@ -5,7 +5,7 @@ namespace OSS\Tests;
use OSS\Model\WebsiteConfig;
-class WebsiteConfigTest extends \PHPUnit_Framework_TestCase
+class WebsiteConfigTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<