API | Operation | Description |
Setting versioning | Sets versioning for a bucket | |
Querying versioning | Queries the versioning information of a bucket |
// Enable versioningQCloudPutBucketVersioningRequest* request = [[QCloudPutBucketVersioningRequest alloc] init];// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket =@"examplebucket-1250000000";// Specific versioning configurationQCloudBucketVersioningConfiguration* versioningConfiguration =[[QCloudBucketVersioningConfiguration alloc] init];request.configuration = versioningConfiguration;// Indicate whether versioning is enabled. Enumerated values: QCloudCOSBucketVersioningStatusEnabled,// QCloudCOSBucketVersioningStatusSuspendedversioningConfiguration.status = QCloudCOSBucketVersioningStatusEnabled;[request setFinishBlock:^(id outputObject, NSError* error) {// `outputObject` contains all the HTTP response headersNSDictionary* info = (NSDictionary *) outputObject;}];[[QCloudCOSXMLService defaultCOSXML] PutBucketVersioning:request];
// Enable versioninglet putBucketVersioning = QCloudPutBucketVersioningRequest.init();// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketputBucketVersioning.bucket = "examplebucket-1250000000";// Specific versioning configurationlet config = QCloudBucketVersioningConfiguration.init();// Indicates whether versioning is enabled. Enumerated values: Suspended, Enabledconfig.status = .enabled;putBucketVersioning.configuration = config;putBucketVersioning.finishBlock = {(result,error) inif let result = result {// "result" contains response headers.} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().putBucketVersioning(putBucketVersioning);
QCloudGetBucketVersioningRequest* request =[[QCloudGetBucketVersioningRequest alloc] init];// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketrequest.bucket = @"examplebucket-1250000000";[request setFinishBlock:^(QCloudBucketVersioningConfiguration* result,NSError* error) {// Get the versioning statusQCloudCOSBucketVersioningStatus * status = result.status;}];[[QCloudCOSXMLService defaultCOSXML] GetBucketVersioning:request];
let getBucketVersioning = QCloudGetBucketVersioningRequest.init();// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucketgetBucketVersioning.bucket = "examplebucket-1250000000";getBucketVersioning.setFinish { (config, error) inif let config = config {// Versioning statuslet status = config.status} else {print(error!);}}QCloudCOSXMLService.defaultCOSXML().getBucketVersioning(getBucketVersioning);
Apakah halaman ini membantu?