提交的内容

This commit is contained in:
2025-05-12 15:45:02 +08:00
parent 629c4750da
commit b48c692775
3043 changed files with 34732 additions and 60810 deletions

0
vendor/aliyuncs/oss-sdk-php/samples/Bucket.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketCname.php vendored Executable file → Normal file
View File

67
vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php vendored Executable file → Normal file
View File

@ -26,7 +26,39 @@ Common::println("bucket $bucket corsConfig created:" . $corsConfig->serializeToX
// Get cors configuration
$corsConfig = $ossClient->getBucketCors($bucket);
Common::println("bucket $bucket corsConfig fetched:" . $corsConfig->serializeToXml());
if ($corsConfig->getResponseVary()){
printf("Response Vary : true" .PHP_EOL);
}else{
printf("Response Vary : false" .PHP_EOL);
}
foreach ($corsConfig->getRules() as $key => $rule){
if($rule->getAllowedHeaders()){
foreach($rule->getAllowedHeaders() as $header){
printf("Allowed Headers :" .$header .PHP_EOL);
}
}
if ($rule->getAllowedMethods()){
foreach($rule->getAllowedMethods() as $method){
printf("Allowed Methods :" .$method . PHP_EOL);
}
}
if($rule->getAllowedOrigins()){
foreach($rule->getAllowedOrigins() as $origin){
printf("Allowed Origins :" .$origin , PHP_EOL);
}
}
if($rule->getExposeHeaders()){
foreach($rule->getExposeHeaders() as $exposeHeader){
printf("Expose Headers :" .$exposeHeader . PHP_EOL);
}
}
printf("Max Age Seconds :" .$rule->getMaxAgeSeconds() .PHP_EOL);
}
// Delete cors configuration
$ossClient->deleteBucketCors($bucket);
@ -78,13 +110,44 @@ function getBucketCors($ossClient, $bucket)
$corsConfig = null;
try {
$corsConfig = $ossClient->getBucketCors($bucket);
if ($corsConfig->getResponseVary()){
printf("Response Vary : true" .PHP_EOL);
}else{
printf("Response Vary : false" .PHP_EOL);
}
foreach ($corsConfig->getRules() as $key => $rule){
if($rule->getAllowedHeaders()){
foreach($rule->getAllowedHeaders() as $header){
printf("Allowed Headers :" .$header .PHP_EOL);
}
}
if ($rule->getAllowedMethods()){
foreach($rule->getAllowedMethods() as $method){
printf("Allowed Methods :" .$method . PHP_EOL);
}
}
if($rule->getAllowedOrigins()){
foreach($rule->getAllowedOrigins() as $origin){
printf("Allowed Origins :" .$origin , PHP_EOL);
}
}
if($rule->getExposeHeaders()){
foreach($rule->getExposeHeaders() as $exposeHeader){
printf("Expose Headers :" .$exposeHeader . PHP_EOL);
}
}
printf("Max Age Seconds :" .$rule->getMaxAgeSeconds() .PHP_EOL);
}
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
print($corsConfig->serializeToXml() . "\n");
}
/**

0
vendor/aliyuncs/oss-sdk-php/samples/BucketEncryption.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketPayment.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketPolicy.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketStat.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketTags.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketTransferAcceleration.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketVersion.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/BucketWorm.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/Callback.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/Common.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/Config.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/CredentialsPhp.php vendored Executable file → Normal file
View File

18
vendor/aliyuncs/oss-sdk-php/samples/CredentialsProvider.php vendored Executable file → Normal file
View File

@ -4,6 +4,7 @@ require_once __DIR__ . '/Common.php';
use OSS\OssClient;
use OSS\Core\OssException;
use OSS\Credentials\StaticCredentialsProvider;
use OSS\Credentials\EnvironmentVariableCredentialsProvider;
$bucket = Common::getBucketName();
// Access Key Provider demo
@ -43,3 +44,20 @@ try {
printf($e->getMessage() . "\n");
return;
}
// read from env
$envProvider = new EnvironmentVariableCredentialsProvider();
$config = array(
'provider' => $envProvider,
'endpoint'=> "<endpoint>"
);
try {
$ossClient = new OssClient($config);
$ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of sts provider');
$result = $ossClient->getObject($bucket,'c.file');
var_dump($result);
} catch (OssException $e) {
printf($e->getMessage() . "\n");
return;
}

0
vendor/aliyuncs/oss-sdk-php/samples/Image.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php vendored Executable file → Normal file
View File

270
vendor/aliyuncs/oss-sdk-php/samples/Object.php vendored Executable file → Normal file
View File

@ -55,7 +55,7 @@ $day = 3;
$tier = 'Expedited';
$config = new RestoreConfig($day,$tier);
$options = array(
OssClient::OSS_RESTORE_CONFIG => $config
OssClient::OSS_RESTORE_CONFIG => $config
);
$ossClient->restoreObject($bucket, 'b.file',$options);
@ -93,9 +93,9 @@ $content = "hello world";
// The speed limit is 100 KB/s, which is 819200 bit/s.
$options = array(
OssClient::OSS_HEADERS => array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
));
OssClient::OSS_HEADERS => array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
));
// Speed limit upload.
$ossClient->putObject($bucket, $object, $content, $options);
@ -205,7 +205,7 @@ function uploadFile($ossClient, $bucket)
}
/**
* Lists all files and folders in the bucket.
* Lists all files and folders in the bucket.
* Note if there's more items than the max-keys specified, the caller needs to use the nextMarker returned as the value for the next call's maker paramter.
* Loop through all the items returned from ListObjects.
*
@ -227,30 +227,47 @@ function listObjects($ossClient, $bucket)
);
try {
$listObjectInfo = $ossClient->listObjects($bucket, $options);
printf("Bucket Name: %s". "\n",$listObjectInfo->getBucketName());
printf("Prefix: %s". "\n",$listObjectInfo->getPrefix());
printf("Marker: %s". "\n",$listObjectInfo->getMarker());
printf("Next Marker: %s". "\n",$listObjectInfo->getNextMarker());
printf("Max Keys: %s". "\n",$listObjectInfo->getMaxKeys());
printf("Delimiter: %s". "\n",$listObjectInfo->getDelimiter());
printf("Is Truncated: %s". "\n",$listObjectInfo->getIsTruncated());
$objectList = $listObjectInfo->getObjectList(); // object list
$prefixList = $listObjectInfo->getPrefixList(); // directory list
if (!empty($objectList)) {
print("objectList:\n");
foreach ($objectList as $objectInfo) {
printf("Object Name: %s". "\n",$objectInfo->getKey());
printf("Object Size: %s". "\n",$objectInfo->getSize());
printf("Object Type: %s". "\n",$objectInfo->getType());
printf("Object ETag: %s". "\n",$objectInfo->getETag());
printf("Object Last Modified: %s". "\n",$objectInfo->getLastModified());
printf("Object Storage Class: %s". "\n",$objectInfo->getStorageClass());
if ($objectInfo->getRestoreInfo()){
printf("Restore Info: %s". "\n",$objectInfo->getRestoreInfo() );
}
if($objectInfo->getOwner()){
printf("Owner Id:".$objectInfo->getOwner()->getId() . "\n");
printf("Owner Name:".$objectInfo->getOwner()->getDisplayName() . "\n");
}
}
}
if (!empty($prefixList)) {
print("prefixList: \n");
foreach ($prefixList as $prefixInfo) {
printf("Common Prefix:%s\n",$prefixInfo->getPrefix());
}
}
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
$objectList = $listObjectInfo->getObjectList(); // object list
$prefixList = $listObjectInfo->getPrefixList(); // directory list
if (!empty($objectList)) {
print("objectList:\n");
foreach ($objectList as $objectInfo) {
print($objectInfo->getKey() . "\n");
if($objectInfo->getOwner() != null){
printf("owner id:".$objectInfo->getOwner()->getId() . "\n");
printf("owner name:".$objectInfo->getOwner()->getDisplayName() . "\n");
}
}
}
if (!empty($prefixList)) {
print("prefixList: \n");
foreach ($prefixList as $prefixInfo) {
print($prefixInfo->getPrefix() . "\n");
}
}
}
/**
@ -264,42 +281,61 @@ function listObjects($ossClient, $bucket)
*/
function listObjectsV2($ossClient, $bucket)
{
$prefix = 'oss-php-sdk-test/';
$delimiter = '/';
$maxkeys = 1000;
$options = array(
'delimiter' => $delimiter,
'prefix' => $prefix,
'max-keys' => $maxkeys,
'start-after' =>'test-object',
'fetch-owner' =>'true',
);
try {
$listObjectInfo = $ossClient->listObjectsV2($bucket, $options);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
$objectList = $listObjectInfo->getObjectList(); // object list
$prefixList = $listObjectInfo->getPrefixList(); // directory list
if (!empty($objectList)) {
print("objectList:\n");
foreach ($objectList as $objectInfo) {
print($objectInfo->getKey() . "\n");
if($objectInfo->getOwner() != null){
printf("owner id:".$objectInfo->getOwner()->getId() . "\n");
printf("owner name:".$objectInfo->getOwner()->getDisplayName() . "\n");
}
}
}
if (!empty($prefixList)) {
print("prefixList: \n");
foreach ($prefixList as $prefixInfo) {
print($prefixInfo->getPrefix() . "\n");
}
}
$prefix = 'oss-php-sdk-test/';
$delimiter = '/';
$maxkeys = 1000;
$options = array(
'delimiter' => $delimiter,
'prefix' => $prefix,
'max-keys' => $maxkeys,
'start-after' =>'test-object',
'fetch-owner' =>'true',
);
try {
$listObjectInfo = $ossClient->listObjectsV2($bucket, $options);
printf("Bucket Name: %s". "\n",$listObjectInfo->getBucketName());
printf("Prefix: %s". "\n",$listObjectInfo->getPrefix());
printf("Next Continuation Token: %s". "\n",$listObjectInfo->getNextContinuationToken());
printf("Continuation Token: %s". "\n",$listObjectInfo->getContinuationToken());
printf("Max Keys: %s". "\n",$listObjectInfo->getMaxKeys());
printf("Key Count: %s". "\n",$listObjectInfo->getKeyCount());
printf("Delimiter: %s". "\n",$listObjectInfo->getDelimiter());
printf("Is Truncated: %s". "\n",$listObjectInfo->getIsTruncated());
printf("Start After: %s". "\n",$listObjectInfo->getStartAfter());
$objectList = $listObjectInfo->getObjectList(); // object list
$prefixList = $listObjectInfo->getPrefixList(); // directory list
if (!empty($objectList)) {
print("objectList:\n");
foreach ($objectList as $objectInfo) {
printf("Object Name: %s". "\n",$objectInfo->getKey());
printf("Object Size: %s". "\n",$objectInfo->getSize());
printf("Object Type: %s". "\n",$objectInfo->getType());
printf("Object ETag: %s". "\n",$objectInfo->getETag());
printf("Object Last Modified: %s". "\n",$objectInfo->getLastModified());
printf("Object Storage Class: %s". "\n",$objectInfo->getStorageClass());
if ($objectInfo->getRestoreInfo()){
printf("Restore Info: %s". "\n",$objectInfo->getRestoreInfo() );
}
if($objectInfo->getOwner()){
printf("Owner Id:".$objectInfo->getOwner()->getId() . "\n");
printf("Owner Name:".$objectInfo->getOwner()->getDisplayName() . "\n");
}
}
}
if (!empty($prefixList)) {
print("prefixList: \n");
foreach ($prefixList as $prefixInfo) {
printf("Common Prefix:%s\n",$prefixInfo->getPrefix());
}
}
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
/**
@ -623,20 +659,20 @@ function doesObjectExist($ossClient, $bucket)
*/
function putObjectSpeed($ossClient, $bucket)
{
$object = "upload-test-object-name.txt";
$content = file_get_contents(__FILE__);
$options = array(
OssClient::OSS_HEADERS => array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
));
try {
$ossClient->putObject($bucket, $object, $content, $options);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
$object = "upload-test-object-name.txt";
$content = file_get_contents(__FILE__);
$options = array(
OssClient::OSS_HEADERS => array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
));
try {
$ossClient->putObject($bucket, $object, $content, $options);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
/**
@ -648,19 +684,19 @@ function putObjectSpeed($ossClient, $bucket)
*/
function getObjectSpeed($ossClient, $bucket)
{
$object = "upload-test-object-name.txt";
$options = array(
OssClient::OSS_HEADERS => array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
));
try {
$ossClient->getObject($bucket, $object, $options);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
$object = "upload-test-object-name.txt";
$options = array(
OssClient::OSS_HEADERS => array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
));
try {
$ossClient->getObject($bucket, $object, $options);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
/**
@ -672,14 +708,14 @@ function getObjectSpeed($ossClient, $bucket)
*/
function signUrlSpeedUpload($ossClient, $bucket)
{
$object = "upload-test-object-name.txt";
$timeout = 120;
$options = array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
);
$timeout = 60;
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options);
print($signedUrl);
$object = "upload-test-object-name.txt";
$timeout = 120;
$options = array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
);
$timeout = 60;
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options);
print($signedUrl);
}
@ -692,14 +728,14 @@ function signUrlSpeedUpload($ossClient, $bucket)
*/
function signUrlSpeedDownload($ossClient, $bucket)
{
$object = "upload-test-object-name.txt";
$timeout = 120;
$options = array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
);
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "GET", $options);
print($signedUrl);
print(__FUNCTION__ . ": OK" . "\n");
$object = "upload-test-object-name.txt";
$timeout = 120;
$options = array(
OssClient::OSS_TRAFFIC_LIMIT => 819200,
);
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "GET", $options);
print($signedUrl);
print(__FUNCTION__ . ": OK" . "\n");
}
/**
@ -711,19 +747,19 @@ function signUrlSpeedDownload($ossClient, $bucket)
*/
function restoreObject($ossClient, $bucket)
{
$object = "oss-php-sdk-test/upload-test-object-name.txt";
$day = 3;
$tier = 'Expedited';
$config = new RestoreConfig($day,$tier);
$options = array(
OssClient::OSS_RESTORE_CONFIG => $config
);
try {
$ossClient->restoreObject($bucket, $object,$options);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
$object = "oss-php-sdk-test/upload-test-object-name.txt";
$day = 3;
$tier = 'Expedited';
$config = new RestoreConfig($day,$tier);
$options = array(
OssClient::OSS_RESTORE_CONFIG => $config
);
try {
$ossClient->restoreObject($bucket, $object,$options);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}

0
vendor/aliyuncs/oss-sdk-php/samples/ObjectTagging.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/RunAll.php vendored Executable file → Normal file
View File

0
vendor/aliyuncs/oss-sdk-php/samples/Signature.php vendored Executable file → Normal file
View File