码迷,mamicode.com
首页 > 其他好文 > 详细

oss文件删除策略

时间:2015-12-23 22:57:35      阅读:886      评论:0      收藏:0      [点我收藏+]

标签:

当你想删除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);

oss文件删除策略

标签:

原文地址:http://www.cnblogs.com/anxiang/p/5071426.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!