use of com.aliyun.oss.model.SetBucketLifecycleRequest in project feeyo-hlsserver by variflight.
the class OssUtil method updateExpirationDays.
/**
* 更新生命周期
*/
public void updateExpirationDays(int days) {
// 获取生命周期规则列表
List<LifecycleRule> list = ossClient.getBucketLifecycle(bucketName);
if (list.size() > 0) {
LifecycleRule lifecycleRule = list.get(0);
List<StorageTransition> storageTransitionList = lifecycleRule.getStorageTransition();
if (storageTransitionList.size() > 0) {
StorageTransition storageTransition = storageTransitionList.get(0);
// 如果原转换到归档存储的时间 与设定时间不一样,则更新
if (storageTransition.getExpirationDays() != days) {
storageTransition.setExpirationDays(days);
SetBucketLifecycleRequest setBucketLifecycleRequest = new SetBucketLifecycleRequest(bucketName);
setBucketLifecycleRequest.setLifecycleRules(list);
ossClient.setBucketLifecycle(setBucketLifecycleRequest);
LOGGER.info("oss life cycle set expir : " + days + " days");
}
}
}
}
Aggregations