框架升级及修复升级后的bug
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
name: CI
|
||||
on: [push, pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
phpunit:
|
||||
name: PHPUnit (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest]
|
||||
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
|
||||
steps:
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
extensions: curl, mbstring, openssl, xml
|
||||
coverage: none
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --ansi --prefer-dist --no-interaction --no-progress
|
||||
|
||||
- name: PHPUnit Migrate Configuration
|
||||
if: ${{ matrix.php-version >= '8.0' }}
|
||||
run: vendor/bin/phpunit --migrate-configuration
|
||||
|
||||
- name: Run Unit Tests (PHP 5.6 - 8.0)
|
||||
if: ${{ matrix.php-version < '8.1' }}
|
||||
run: vendor/bin/phpunit --testsuite UnitTest
|
||||
env:
|
||||
PHP_ERROR_REPORTING: E_ALL
|
||||
|
||||
- name: Run Unit Tests (PHP 8.1+)
|
||||
if: ${{ matrix.php-version >= '8.1' }}
|
||||
run: vendor/bin/phpunit --testsuite UnitTest --fail-on-deprecation --display-deprecations
|
||||
env:
|
||||
PHP_ERROR_REPORTING: E_ALL
|
||||
@@ -0,0 +1,35 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build-phar:
|
||||
name: Build PHAR
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.4'
|
||||
extensions: phar, curl, mbstring, openssl, xml
|
||||
tools: phar-composer
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-dev --prefer-dist --no-interaction --no-progress
|
||||
|
||||
- name: Build PHAR
|
||||
run: |
|
||||
version=$(grep 'const OSS_VERSION' src/OSS/OssClient.php | grep -oE '[0-9.]+')
|
||||
phar-composer build . aliyun-oss-php-sdk-${version}.phar
|
||||
|
||||
- name: Upload to Release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
version=$(grep 'const OSS_VERSION' src/OSS/OssClient.php | grep -oE '[0-9.]+')
|
||||
gh release upload ${{ github.event.release.tag_name }} aliyun-oss-php-sdk-${version}.phar
|
||||
@@ -1,5 +1,9 @@
|
||||
# ChangeLog - Aliyun OSS SDK for PHP
|
||||
|
||||
## v2.7.3 / 2026-06-26
|
||||
* Compatible with PHP8.5
|
||||
|
||||
|
||||
## v2.7.2 / 2024-10-28
|
||||
* Added: presign supports response-* parameters
|
||||
* Added: forcePathStyle option.
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
|
||||
## [README of English](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README.md)
|
||||
|
||||
## 关于 OSS SDK for PHP V2
|
||||
> - OSS SDK for PHP V2([alibabacloud-oss-php-sdk-v2](https://github.com/aliyun/alibabacloud-oss-php-sdk-v2)) 测试版已发布, 是对V1(aliyun-oss-php-sdk)代码库的重大改写。
|
||||
> - V2是一个全新的版本,简化了底层操作例如身份验证、自动请求重试及错误处理等;提供了灵活友好的参数配置以及丰富的高级接口,例如分页器、传输管理器等,全面提升了开发效率和体验。
|
||||
|
||||
|
||||
## 概述
|
||||
|
||||
阿里云对象存储(Object Storage Service,简称OSS),是阿里云对外提供的海量、安全、低成本、高可靠的云存储服务。用户可以通过调用API,在任何应用、任何时间、任何地点上传和下载数据,也可以通过用户Web控制台对数据进行简单的管理。OSS适合存放任意文件类型,适合各种网站、开发企业及开发者使用。
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
|
||||
## [README of Chinese](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README-CN.md)
|
||||
|
||||
## About OSS SDK for PHP V2
|
||||
> - OSS SDK for PHP V2([alibabacloud-oss-php-sdk-v2](https://github.com/aliyun/alibabacloud-oss-php-sdk-v2)) beta version has been released, it is a major rewrite of OSS SDK for PHP V1 (aliyun-oss-php-sdk).
|
||||
> - V2 simplifies underlying operations such as identification authentication, automatic retry of failed requests, and error handling. It provides flexible parameter configuration methods and rich advanced operations, such as paginator, transmission managers. This comprehensively improves development efficiency and experience.
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring a massive capacity, security, a low cost, and high reliability. You can upload and download data on any application anytime and anywhere by calling APIs, and perform simple management of data through the web console. The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.
|
||||
|
||||
+91
-4
@@ -7,13 +7,100 @@
|
||||
<directory suffix=".php">./src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="coverage.xml" />
|
||||
</logging>
|
||||
<testsuites>
|
||||
<testsuite name="FunctionTest">
|
||||
<!-- Unit Tests: 43 files, no OSS credentials required -->
|
||||
<testsuite name="UnitTest">
|
||||
<directory>./tests</directory>
|
||||
<!-- Helper/Base files -->
|
||||
<exclude>./tests/OSS/Tests/Common.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/TestOssClientBase.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/StsClient.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/AssumeRole.php</exclude>
|
||||
<!-- Integration tests: extends TestCase but requires OSS credentials -->
|
||||
<exclude>./tests/OSS/Tests/BucketCnameTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/BucketLiveChannelTest.php</exclude>
|
||||
<!-- Integration tests: extends TestOssClientBase -->
|
||||
<exclude>./tests/OSS/Tests/CallbackTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/ContentTypeTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/ObjectAclTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientAsyncProcessObjectTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketCnameTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketCorsTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketEncryptionTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketInfoTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketLifecycleTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketLoggingTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketPolicyTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketRequestPaymentTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketRefererTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketStatTestTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketStorageCapacityTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketTagsTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketVersioningTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketWebsiteTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientBucketWormTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientForcePathStyleTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientImageTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientListObjectsTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientListObjectsV2Test.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientMultipartUploadTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientObjectRequestPaymentTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientObjectTaggingTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientObjectTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientObjectVersioningTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientPresignTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientPresignV4Test.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientRestoreObjectTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientSignatureTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientSignatureV4Test.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssClientTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/OssTrafficLimitTest.php</exclude>
|
||||
<exclude>./tests/OSS/Tests/SymlinkTest.php</exclude>
|
||||
</testsuite>
|
||||
<!-- Integration Tests: 41 files, requires OSS credentials -->
|
||||
<testsuite name="IntegrationTest">
|
||||
<file>./tests/OSS/Tests/BucketCnameTest.php</file>
|
||||
<file>./tests/OSS/Tests/BucketLiveChannelTest.php</file>
|
||||
<file>./tests/OSS/Tests/CallbackTest.php</file>
|
||||
<file>./tests/OSS/Tests/ContentTypeTest.php</file>
|
||||
<file>./tests/OSS/Tests/ObjectAclTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientAsyncProcessObjectTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketCnameTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketCorsTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketEncryptionTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketInfoTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketLifecycleTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketLoggingTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketPolicyTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketRequestPaymentTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketRefererTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketStatTestTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketStorageCapacityTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketTagsTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketVersioningTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketWebsiteTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientBucketWormTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientForcePathStyleTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientImageTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientListObjectsTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientListObjectsV2Test.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientMultipartUploadTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientObjectRequestPaymentTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientObjectTaggingTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientObjectTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientObjectVersioningTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientPresignTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientPresignV4Test.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientRestoreObjectTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientSignatureTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientSignatureV4Test.php</file>
|
||||
<file>./tests/OSS/Tests/OssClientTest.php</file>
|
||||
<file>./tests/OSS/Tests/OssTrafficLimitTest.php</file>
|
||||
<file>./tests/OSS/Tests/SymlinkTest.php</file>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
|
||||
@@ -91,8 +91,8 @@ function putObjectByRawApis($ossClient, $bucket)
|
||||
$uploadPosition = 0;
|
||||
$isCheckMd5 = true;
|
||||
foreach ($pieces as $i => $piece) {
|
||||
$fromPos = $uploadPosition + (integer)$piece[$ossClient::OSS_SEEK_TO];
|
||||
$toPos = (integer)$piece[$ossClient::OSS_LENGTH] + $fromPos - 1;
|
||||
$fromPos = $uploadPosition + (int)$piece[$ossClient::OSS_SEEK_TO];
|
||||
$toPos = (int)$piece[$ossClient::OSS_LENGTH] + $fromPos - 1;
|
||||
$upOptions = array(
|
||||
$ossClient::OSS_FILE_UPLOAD => $uploadFile,
|
||||
$ossClient::OSS_PART_NUM => ($i + 1),
|
||||
|
||||
@@ -104,8 +104,8 @@ $response_upload_part = array();
|
||||
$copyId = 1;
|
||||
$upload_position = 0;
|
||||
foreach ($pieces as $i => $piece) {
|
||||
$from_pos = $upload_position + (integer)$piece['seekTo'];
|
||||
$to_pos = (integer)$piece['length'] + $from_pos - 1;
|
||||
$from_pos = $upload_position + (int)$piece['seekTo'];
|
||||
$to_pos = (int)$piece['length'] + $from_pos - 1;
|
||||
$up_options = array(
|
||||
'start' => $from_pos,
|
||||
'end' => $to_pos,
|
||||
@@ -333,8 +333,8 @@ function copyObjectLarge($ossClient,$bucket){
|
||||
$copyId = 1;
|
||||
$upload_position = 0;
|
||||
foreach ($pieces as $i => $piece) {
|
||||
$from_pos = $upload_position + (integer)$piece['seekTo'];
|
||||
$to_pos = (integer)$piece['length'] + $from_pos - 1;
|
||||
$from_pos = $upload_position + (int)$piece['seekTo'];
|
||||
$to_pos = (int)$piece['length'] + $from_pos - 1;
|
||||
$up_options = array(
|
||||
'start' => $from_pos,
|
||||
'end' => $to_pos,
|
||||
|
||||
@@ -475,7 +475,7 @@ class RequestCore
|
||||
*/
|
||||
public function set_seek_position($position)
|
||||
{
|
||||
$this->seek_position = isset($position) ? (integer)$position : null;
|
||||
$this->seek_position = isset($position) ? (int)$position : null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -849,7 +849,10 @@ class RequestCore
|
||||
|
||||
$parsed_response = $this->process_response($curl_handle, $this->response);
|
||||
|
||||
curl_close($curl_handle);
|
||||
|
||||
if (PHP_VERSION_ID < 80500) {
|
||||
curl_close($curl_handle);
|
||||
}
|
||||
unset($curl_handle);
|
||||
|
||||
if ($parse) {
|
||||
|
||||
+13
-13
@@ -2392,7 +2392,7 @@ class OssClient
|
||||
*/
|
||||
private function computePartSize($partSize)
|
||||
{
|
||||
$partSize = (integer)$partSize;
|
||||
$partSize = (int)$partSize;
|
||||
if ($partSize <= self::OSS_MIN_PART_SIZE) {
|
||||
$partSize = self::OSS_MIN_PART_SIZE;
|
||||
} elseif ($partSize > self::OSS_MAX_PART_SIZE) {
|
||||
@@ -2676,10 +2676,10 @@ class OssClient
|
||||
$options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $uploadFile);
|
||||
}
|
||||
|
||||
$upload_position = isset($options[self::OSS_SEEK_TO]) ? (integer)$options[self::OSS_SEEK_TO] : 0;
|
||||
$upload_position = isset($options[self::OSS_SEEK_TO]) ? (int)$options[self::OSS_SEEK_TO] : 0;
|
||||
|
||||
if (isset($options[self::OSS_CONTENT_LENGTH])) {
|
||||
$upload_file_size = (integer)$options[self::OSS_CONTENT_LENGTH];
|
||||
$upload_file_size = (int)$options[self::OSS_CONTENT_LENGTH];
|
||||
} else {
|
||||
$upload_file_size = sprintf('%u', filesize($uploadFile));
|
||||
|
||||
@@ -2713,11 +2713,11 @@ class OssClient
|
||||
}
|
||||
|
||||
// generates the parts information and upload them one by one
|
||||
$pieces = $this->generateMultiuploadParts($upload_file_size, (integer)$options[self::OSS_PART_SIZE]);
|
||||
$pieces = $this->generateMultiuploadParts($upload_file_size, (int)$options[self::OSS_PART_SIZE]);
|
||||
$response_upload_part = array();
|
||||
foreach ($pieces as $i => $piece) {
|
||||
$from_pos = $upload_position + (integer)$piece[self::OSS_SEEK_TO];
|
||||
$to_pos = (integer)$piece[self::OSS_LENGTH] + $from_pos - 1;
|
||||
$from_pos = $upload_position + (int)$piece[self::OSS_SEEK_TO];
|
||||
$to_pos = (int)$piece[self::OSS_LENGTH] + $from_pos - 1;
|
||||
$up_options = array(
|
||||
self::OSS_FILE_UPLOAD => $uploadFile,
|
||||
self::OSS_PART_NUM => ($i + 1),
|
||||
@@ -3102,7 +3102,7 @@ class OssClient
|
||||
} elseif (isset($options[self::OSS_SEEK_TO])) {
|
||||
$stats = fstat($options[self::OSS_FILE_UPLOAD]);
|
||||
if ($stats && $stats[self::OSS_SIZE] >= 0) {
|
||||
$length = $stats[self::OSS_SIZE] - (integer)$options[self::OSS_SEEK_TO];
|
||||
$length = $stats[self::OSS_SIZE] - (int)$options[self::OSS_SEEK_TO];
|
||||
}
|
||||
}
|
||||
$request->set_read_stream($options[self::OSS_FILE_UPLOAD], $length);
|
||||
@@ -3112,13 +3112,13 @@ class OssClient
|
||||
if (isset($options[self::OSS_CONTENT_LENGTH])) {
|
||||
$length = $options[self::OSS_CONTENT_LENGTH];
|
||||
} elseif (isset($options[self::OSS_SEEK_TO]) && isset($length)) {
|
||||
$length -= (integer)$options[self::OSS_SEEK_TO];
|
||||
$length -= (int)$options[self::OSS_SEEK_TO];
|
||||
}
|
||||
$request->set_read_stream_size($length);
|
||||
}
|
||||
}
|
||||
if (isset($options[self::OSS_SEEK_TO])) {
|
||||
$request->set_seek_position((integer)$options[self::OSS_SEEK_TO]);
|
||||
$request->set_seek_position((int)$options[self::OSS_SEEK_TO]);
|
||||
}
|
||||
if (isset($options[self::OSS_FILE_DOWNLOAD])) {
|
||||
if (is_resource($options[self::OSS_FILE_DOWNLOAD])) {
|
||||
@@ -3197,10 +3197,10 @@ class OssClient
|
||||
|
||||
$data = new ResponseCore($response_header, $request->get_response_body(), $request->get_response_code());
|
||||
//retry if OSS Internal Error
|
||||
if ((integer)$request->get_response_code() === 500) {
|
||||
if ((int)$request->get_response_code() === 500) {
|
||||
if ($this->redirects <= $this->maxRetries) {
|
||||
//Sets the sleep time betwen each retry.
|
||||
$delay = (integer)(pow(4, $this->redirects) * 100000);
|
||||
$delay = (int)(pow(4, $this->redirects) * 100000);
|
||||
usleep($delay);
|
||||
$this->redirects++;
|
||||
$data = $this->auth($options);
|
||||
@@ -3760,8 +3760,8 @@ class OssClient
|
||||
);
|
||||
// OssClient version information
|
||||
const OSS_NAME = "aliyun-sdk-php";
|
||||
const OSS_VERSION = "2.7.2";
|
||||
const OSS_BUILD = "20241028";
|
||||
const OSS_VERSION = "2.7.3";
|
||||
const OSS_BUILD = "20260626";
|
||||
const OSS_AUTHOR = "";
|
||||
const OSS_OPTIONS_ORIGIN = 'Origin';
|
||||
const OSS_OPTIONS_REQUEST_METHOD = 'Access-Control-Request-Method';
|
||||
|
||||
@@ -19,9 +19,9 @@ class ObjectAclTest extends TestOssClientBase
|
||||
$acl = $client->getObjectAcl($bucket, $object);
|
||||
$this->assertEquals('default', $acl);
|
||||
|
||||
$client->putObjectAcl($bucket, $object, 'public-read');
|
||||
$client->putObjectAcl($bucket, $object, 'private');
|
||||
$acl = $client->getObjectAcl($bucket, $object);
|
||||
$this->assertEquals('public-read', $acl);
|
||||
$this->assertEquals('private', $acl);
|
||||
|
||||
$content = $client->getObject($bucket, $object);
|
||||
$this->assertEquals('hello world', $content);
|
||||
|
||||
+3
-1
@@ -28,7 +28,9 @@ class OssClientAsyncProcessObjectTest extends TestOssClientBase
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_FILE, $fp);
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if (PHP_VERSION_ID < 80500) {
|
||||
curl_close($ch);
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
$this->local_file = $file_name;
|
||||
|
||||
+1
-4
@@ -15,10 +15,7 @@ class OssClientBucketCnameTest extends TestOssClientBase
|
||||
public function testBucketCname()
|
||||
{
|
||||
$bucketName = $this->bucket . '-cname';
|
||||
$client = new OssClient(
|
||||
getenv('OSS_ACCESS_KEY_ID'),
|
||||
getenv('OSS_ACCESS_KEY_SECRET'),
|
||||
"oss-ap-southeast-2.aliyuncs.com", false);
|
||||
$client = $this->ossClient;
|
||||
|
||||
$client->createBucket($bucketName);
|
||||
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ class OssClientBucketTest extends TestOssClientBase
|
||||
|
||||
public function testBucket()
|
||||
{
|
||||
$this->ossClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
$this->ossClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PRIVATE);
|
||||
|
||||
$bucketListInfo = $this->ossClient->listBuckets();
|
||||
$this->assertNotNull($bucketListInfo);
|
||||
@@ -45,9 +45,9 @@ class OssClientBucketTest extends TestOssClientBase
|
||||
$this->assertTrue(is_array($bucketList));
|
||||
$this->assertGreaterThan(0, count($bucketList));
|
||||
|
||||
$this->ossClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
$this->ossClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PRIVATE);
|
||||
Common::waitMetaSync();
|
||||
$this->assertEquals($this->ossClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
$this->assertEquals($this->ossClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PRIVATE);
|
||||
|
||||
$this->assertTrue($this->ossClient->doesBucketExist($this->bucket));
|
||||
$this->assertFalse($this->ossClient->doesBucketExist($this->bucket . '-notexist'));
|
||||
|
||||
+6
-6
@@ -158,8 +158,8 @@ class OssClientMultipartUploadTest extends TestOssClientBase
|
||||
$upload_position = 0;
|
||||
$is_check_md5 = true;
|
||||
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;
|
||||
$from_pos = $upload_position + (int)$piece[OssClient::OSS_SEEK_TO];
|
||||
$to_pos = (int)$piece[OssClient::OSS_LENGTH] + $from_pos - 1;
|
||||
$up_options = array(
|
||||
OssClient::OSS_FILE_UPLOAD => $upload_file,
|
||||
OssClient::OSS_PART_NUM => ($i + 1),
|
||||
@@ -237,8 +237,8 @@ class OssClientMultipartUploadTest extends TestOssClientBase
|
||||
$upload_position = 0;
|
||||
$is_check_md5 = true;
|
||||
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;
|
||||
$from_pos = $upload_position + (int)$piece[OssClient::OSS_SEEK_TO];
|
||||
$to_pos = (int)$piece[OssClient::OSS_LENGTH] + $from_pos - 1;
|
||||
$up_options = array(
|
||||
OssClient::OSS_FILE_UPLOAD => $upload_file,
|
||||
OssClient::OSS_PART_NUM => ($i + 1),
|
||||
@@ -423,8 +423,8 @@ class OssClientMultipartUploadTest extends TestOssClientBase
|
||||
$upload_position = 0;
|
||||
$is_check_md5 = true;
|
||||
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;
|
||||
$from_pos = $upload_position + (int)$piece[OssClient::OSS_SEEK_TO];
|
||||
$to_pos = (int)$piece[OssClient::OSS_LENGTH] + $from_pos - 1;
|
||||
$up_options = array(
|
||||
OssClient::OSS_FILE_UPLOAD => $upload_file,
|
||||
OssClient::OSS_PART_NUM => ($i + 1),
|
||||
|
||||
+2
-2
@@ -360,8 +360,8 @@ class OssClientObjectRequestPaymentTest extends TestOssClientBase
|
||||
$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;
|
||||
$from_pos = $upload_position + (int)$piece[OssClient::OSS_SEEK_TO];
|
||||
$to_pos = (int)$piece[OssClient::OSS_LENGTH] + $from_pos - 1;
|
||||
$up_options = array(
|
||||
OssClient::OSS_FILE_UPLOAD => $upload_file,
|
||||
OssClient::OSS_PART_NUM => ($i + 1),
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@ class OssClientObjectVersioningTest extends TestOssClientBase
|
||||
$object = 'object';
|
||||
$content1 = 'hello';
|
||||
$content2 = 'hello world';
|
||||
$ret1 = $this->ossClient->putObject($this->bucket, $object, $content1, array(OssClient::OSS_HEADERS => array('x-oss-object-acl' => 'public-read', 'x-oss-tagging' => 'key1=value1')));
|
||||
$ret1 = $this->ossClient->putObject($this->bucket, $object, $content1, array(OssClient::OSS_HEADERS => array('x-oss-object-acl' => 'private', '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]));
|
||||
@@ -65,14 +65,14 @@ class OssClientObjectVersioningTest extends TestOssClientBase
|
||||
$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', $acl1);
|
||||
$this->assertEquals('private', $acl2);
|
||||
$this->assertEquals('private', $acl);
|
||||
|
||||
$this->ossClient->putObjectAcl($this->bucket, $object, 'public-read-write', array(OssClient::OSS_VERSION_ID => $versionId1));
|
||||
$this->ossClient->putObjectAcl($this->bucket, $object, 'private', 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', $acl1);
|
||||
$this->assertEquals('private', $acl);
|
||||
|
||||
//tagging
|
||||
|
||||
+6
-6
@@ -713,7 +713,7 @@ class OssClientSignatureV4Test extends TestOssClientBase
|
||||
|
||||
public function testBaseInterfaceForBucekt()
|
||||
{
|
||||
$this->ossClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
$this->ossClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PRIVATE);
|
||||
|
||||
$bucketListInfo = $this->ossClient->listBuckets();
|
||||
$this->assertNotNull($bucketListInfo);
|
||||
@@ -722,9 +722,9 @@ class OssClientSignatureV4Test extends TestOssClientBase
|
||||
$this->assertTrue(is_array($bucketList));
|
||||
$this->assertGreaterThan(0, count($bucketList));
|
||||
|
||||
$this->ossClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
$this->ossClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PRIVATE);
|
||||
Common::waitMetaSync();
|
||||
$this->assertEquals($this->ossClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
$this->assertEquals($this->ossClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PRIVATE);
|
||||
|
||||
$this->assertTrue($this->ossClient->doesBucketExist($this->bucket));
|
||||
$this->assertFalse($this->ossClient->doesBucketExist($this->bucket . '-notexist'));
|
||||
@@ -1348,7 +1348,7 @@ class OssClientSignatureV4Test extends TestOssClientBase
|
||||
),
|
||||
OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email')
|
||||
);
|
||||
$this->stsOssClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE, $options);
|
||||
$this->stsOssClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options);
|
||||
|
||||
$bucketListInfo = $this->stsOssClient->listBuckets($options);
|
||||
$this->assertNotNull($bucketListInfo);
|
||||
@@ -1357,9 +1357,9 @@ class OssClientSignatureV4Test extends TestOssClientBase
|
||||
$this->assertTrue(is_array($bucketList));
|
||||
$this->assertGreaterThan(0, count($bucketList));
|
||||
|
||||
$this->stsOssClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE, $options);
|
||||
$this->stsOssClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options);
|
||||
Common::waitMetaSync();
|
||||
$this->assertEquals($this->stsOssClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
$this->assertEquals($this->stsOssClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PRIVATE);
|
||||
|
||||
$this->assertTrue($this->stsOssClient->doesBucketExist($this->bucket));
|
||||
$this->assertFalse($this->stsOssClient->doesBucketExist($this->bucket . '-notexist'));
|
||||
|
||||
-9
@@ -54,13 +54,4 @@ class PutSetDeleteResultTest extends \PHPUnit\Framework\TestCase
|
||||
}
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,9 @@ class StsClient
|
||||
throw new OssException($errors->Code);
|
||||
}
|
||||
|
||||
curl_close($curl_handle);
|
||||
if (PHP_VERSION_ID < 80500) {
|
||||
curl_close($curl_handle);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user