/// 设置存储桶生命周期 public void PutBucketLifecycle() { //.cssg-snippet-body-start:[put-bucket-lifecycle] try { string bucket = "examplebucket-1250000000"; //格式:BucketName-APPID PutBucketLifecycleRequest request = new PutBucketLifecycleRequest(bucket); //设置 lifecycle LifecycleConfiguration.Rule rule = new LifecycleConfiguration.Rule(); rule.id = "lfiecycleConfigureId"; rule.status = "Enabled"; //Enabled,Disabled rule.filter = new COSXML.Model.Tag.LifecycleConfiguration.Filter(); rule.filter.prefix = "2/"; //指定分片过期删除操作 rule.abortIncompleteMultiUpload = new LifecycleConfiguration.AbortIncompleteMultiUpload(); rule.abortIncompleteMultiUpload.daysAfterInitiation = 2; request.SetRule(rule); //执行请求 PutBucketLifecycleResult result = cosXml.PutBucketLifecycle(request); //请求成功 Console.WriteLine(result.GetResultInfo()); } catch (COSXML.CosException.CosClientException clientEx) { //请求失败 Console.WriteLine("CosClientException: " + clientEx); } catch (COSXML.CosException.CosServerException serverEx) { //请求失败 Console.WriteLine("CosServerException: " + serverEx.GetInfo()); } //.cssg-snippet-body-end }