API | Operation | Description |
Setting lifecycle configuration | Sets lifecycle for a bucket | |
Querying a lifecycle configuration | Queries the lifecycle configuration of a bucket | |
Deleting a lifecycle configuration | Deletes the lifecycle configuration of a bucket |
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";PutBucketLifecycleRequest request = new PutBucketLifecycleRequest(bucket);// Set the 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/";// Specify the operation for deleting expired partsrule.abortIncompleteMultiUpload = new LifecycleConfiguration.AbortIncompleteMultiUpload();rule.abortIncompleteMultiUpload.daysAfterInitiation = 2;request.SetRule(rule);// Execute the requestPutBucketLifecycleResult result = cosXml.PutBucketLifecycle(request);// Request succeededConsole.WriteLine(result.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";GetBucketLifecycleRequest request = new GetBucketLifecycleRequest(bucket);// Execute the requestGetBucketLifecycleResult result = cosXml.GetBucketLifecycle(request);// Bucket lifecycle configurationLifecycleConfiguration conf = result.lifecycleConfiguration;}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";DeleteBucketLifecycleRequest request = new DeleteBucketLifecycleRequest(bucket);// Execute the requestDeleteBucketLifecycleResult result = cosXml.DeleteBucketLifecycle(request);// Request succeededConsole.WriteLine(result.GetResultInfo());}catch (COSXML.CosException.CosClientException clientEx){// Request failedConsole.WriteLine("CosClientException: " + clientEx);}catch (COSXML.CosException.CosServerException serverEx){// Request failedConsole.WriteLine("CosServerException: " + serverEx.GetInfo());}
Apakah halaman ini membantu?