文档首页 > > SDK参考> Android> 生命周期管理> 查看生命周期规则

查看生命周期规则

分享
更新时间: 2019/04/19 GMT+08:00

您可以通过ObsClient.getBucketLifecycle查看桶的生命周期规则。以下代码展示了如何查看桶的生命周期规则:

String endPoint = "https://your-endpoint";
String ak = "*** Provide your Access Key ***";
String sk = "*** Provide your Secret Key ***";
// 创建ObsClient实例
ObsClient obsClient = new ObsClient(ak, sk, endPoint);

LifecycleConfiguration config = obsClient.getBucketLifecycle("bucketname");

for (Rule rule : config.getRules()) {
    Log.i("GetBucketLifecycleConfiguration",rule.getId());
    Log.i("GetBucketLifecycleConfiguration",rule.getPrefix());
    for(Transition transition : rule.getTransitions()){
        Log.i("GetBucketLifecycleConfiguration",transition.getDays());
        Log.i("GetBucketLifecycleConfiguration",transition.getStorageClass());
    }
    Log.i("GetBucketLifecycleConfiguration",rule.getExpiration() != null ? rule.getExpiration().getDays() : "");
    for(NoncurrentVersionTransition noncurrentVersionTransition : rule.getNoncurrentVersionTransitions()){
        Log.i("GetBucketLifecycleConfiguration",noncurrentVersionTransition.getDays());
        Log.i("GetBucketLifecycleConfiguration",noncurrentVersionTransition.getStorageClass());
    }
    Log.i("GetBucketLifecycleConfiguration",rule.getNoncurrentVersionExpiration() != null ?rule.getNoncurrentVersionExpiration().getDays() : "");
}
分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

跳转到云社区