oss文件刪除策略

當你想刪除oss服務中某個bucket下的文件夾時,文件夾中又包含了太多文件,遞歸刪除太過耗時,又必須刪除時,此時就要用oss的文件刪除策略,以下所示:java

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);
相關文章
相關標籤/搜索