API | 操作名 | 操作描述 |
设置生命周期 | 设置存储桶的生命周期管理的配置 | |
查询生命周期 | 查询存储桶生命周期管理的配置 | |
删除生命周期 | 删除存储桶生命周期管理的配置 |
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";PutBucketLifecycleRequest request = new PutBucketLifecycleRequest(bucket);//设置 lifecycleLifecycleConfiguration.Rule rule = new LifecycleConfiguration.Rule();rule.id = "lfiecycleConfigureId";rule.status = "Enabled"; //Enabled,Disabledrule.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());}
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";GetBucketLifecycleRequest request = new GetBucketLifecycleRequest(bucket);//执行请求GetBucketLifecycleResult result = cosXml.GetBucketLifecycle(request);//存储桶的生命周期配置LifecycleConfiguration conf = result.lifecycleConfiguration;}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";DeleteBucketLifecycleRequest request = new DeleteBucketLifecycleRequest(bucket);//执行请求DeleteBucketLifecycleResult result = cosXml.DeleteBucketLifecycle(request);//请求成功Console.WriteLine(result.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){//请求失败Console.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){//请求失败Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
本页内容是否解决了您的问题?