标签:
当你想删除oss服务中某个bucket下的文件夹时,文件夹中又包含了太多文件,递归删除太过耗时,又必须删除时,此时就要用oss的文件删除策略,如下所示:
OSSClient client = new OSSClient(endpoint, accessId, accessKey);
SetBucketLifecycleRequest req = new SetBucketLifecycleRequest(bucketName);
// 添加Lifecycle规则
req.AddLifecycleRule(new LifecycleRule("delete obsoleted files", "obsoleted/", RuleStatus.Enabled, 3));
req.AddLifecycleRule(new LifecycleRule("delete temporary files", "temporary/", RuleStatus.Enabled,
DateUtil.parseIso8601Date("2022-10-12T00:00:00.000Z")));
// 设置Bucket Lifecycle
client.setBucketLifecycle(req);
标签:
原文地址:http://www.cnblogs.com/anxiang/p/5071426.html