更新时间:2023-11-08 GMT+08:00
查看生命周期规则
开发过程中,您有任何问题可以在github上提交issue,或者在华为云对象存储服务论坛中发帖求助。接口参考文档详细介绍了每个接口的参数和使用方法。
您可以通过ObsClient->getBucketLifecycle查看桶的生命周期规则。以下代码展示了如何查看桶的生命周期规则:
// 引入依赖库 require 'vendor/autoload.php'; // 使用源码安装时引入SDK代码库 // require 'obs-autoloader.php'; // 声明命名空间 use Obs\ObsClient; // 创建ObsClient实例 $obsClient = new ObsClient ( [ //推荐通过环境变量获取AKSK,这里也可以使用其他外部引入方式传入,如果使用硬编码可能会存在泄露风险。 //您可以登录访问管理控制台获取访问密钥AK/SK,获取方式请参见https://support.huaweicloud.com/usermanual-ca/ca_01_0003.html 'key' => getenv('ACCESS_KEY_ID'), 'secret' => getenv('SECRET_ACCESS_KEY'), 'endpoint' => 'https://your-endpoint' ] ); $resp = $obsClient->getBucketLifecycle ( [ 'Bucket' => 'bucketname' ] ); printf ( "RequestId:%s\n", $resp ['RequestId'] ); foreach ($resp['Rules'] as $index => $rule) { printf("Rules[%d]\n", $index + 1); printf("ID:%s\n", $rule['ID']); printf("Prefix:%s\n", $rule['Prefix']); printf("Status:%s\n", $rule['Status']); foreach ($rule['Transitions'] as $i => $transition) { printf("[Transitions][$i][Date]:%s,[Transitions][$i][StorageClass]:%s\n", $transition['Date'], $transition['StorageClass']); } printf("Expiration[Days]:%s\n", $rule['Expiration']['Days']); printf("Expiration[Date]:%s\n", $rule['Expiration']['Date']); foreach ($rule['NoncurrentVersionTransitions'] as $i => $noncurrentVersionTransition) { printf("[NoncurrentVersionTransitions][$i][NoncurrentDays]:%d,[NoncurrentVersionTransitions][$i][StorageClass]:%s\n", $noncurrentVersionTransition['NoncurrentDays'], $noncurrentVersionTransition['StorageClass']); } printf("NoncurrentVersionExpiration[NoncurrentDays]:%s\n", $rule['NoncurrentVersionExpiration']['NoncurrentDays']); }
父主题: 生命周期管理