API | 操作名 | 操作描述 |
设置版本控制 | 设置存储桶的版本控制功能 | |
查询版本控制 | 查询存储桶的版本控制信息 |
// 开启版本控制QCloudPutBucketVersioningRequest* request = [[QCloudPutBucketVersioningRequest alloc] init];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket =@"examplebucket-1250000000";// 说明版本控制的具体信息QCloudBucketVersioningConfiguration* versioningConfiguration =[[QCloudBucketVersioningConfiguration alloc] init];request.configuration = versioningConfiguration;// 说明版本是否开启,枚举值:QCloudCOSBucketVersioningStatusEnabled、// QCloudCOSBucketVersioningStatusSuspendedversioningConfiguration.status = QCloudCOSBucketVersioningStatusEnabled;[request setFinishBlock:^(id outputObject, NSError* error) {// outputObject 包含所有的响应 http 头部NSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucketVersioning:request];
// 开启版本控制let putBucketVersioning = QCloudPutBucketVersioningRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketputBucketVersioning.bucket = "examplebucket-1250000000";// 说明版本控制的具体信息let config = QCloudBucketVersioningConfiguration.init();// 说明版本是否开启,枚举值:Suspended、Enabledconfig.status = .enabled;putBucketVersioning.configuration = config;putBucketVersioning.finishBlock = {(result,error) inif let result = result {// result 包含响应的 header 信息} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketVersioning(putBucketVersioning);
QCloudGetBucketVersioningRequest* request =[[QCloudGetBucketVersioningRequest alloc] init];// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(QCloudBucketVersioningConfiguration* result,NSError* error) {// 获取多版本状态QCloudCOSBucketVersioningStatus * status = result.status;}];[[QCloudCOSXMLService defaultCOSXML] GetBucketVersioning:request];
let getBucketVersioning = QCloudGetBucketVersioningRequest.init();// 存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucketgetBucketVersioning.bucket = "examplebucket-1250000000";getBucketVersioning.setFinish { (config, error) inif let config = config {// 多版本状态let status = config.status} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucketVersioning(getBucketVersioning);
本页内容是否解决了您的问题?