tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Cross-region replication

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2024-01-23 17:15:08

Overview

This document provides an overview of APIs and SDK code samples related to cross-region replication.
API
Operation
Description
Setting a cross-region replication rule
Sets a cross-region replication rule for a bucket
Querying a cross-region replication rule
Queries the cross-region replication rule of a bucket
Deleting a cross-region replication rule
Deletes the cross-region replication rule from a bucket

SDK API References

For parameters and method description of all APIs in the SDK, please see SDK API Reference.

Setting Cross-region Replication Rules

Description

This API is used to set the cross-region replication rules of a specified bucket.

Sample code

Objective-C
QCloudPutBucketReplicationRequest* request = [[QCloudPutBucketReplicationRequest alloc] init];

// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
request.bucket = @"examplebucket-1250000000";

// All cross-region replication configuration information
QCloudBucketReplicationConfiguation* replConfiguration =
[[QCloudBucketReplicationConfiguation alloc] init];

// Initiator ID
replConfiguration.role = @"qcs::cam::uin/100000000001:uin/100000000001";

// Specific configuration information
QCloudBucketReplicationRule* rule = [[QCloudBucketReplicationRule alloc] init];

// Identify the name of a specific rule
rule.identifier = @"identifier";
rule.status = QCloudCOSXMLStatusEnabled;

// Resource ID
QCloudBucketReplicationDestination* destination = [[QCloudBucketReplicationDestination alloc] init];
NSString* destinationBucket = @"destinationbucket-1250000000";

// Destination bucket region
NSString* region = @"ap-beijing";
destination.bucket = [NSString stringWithFormat:@"qcs::cos:%@::%@",region,destinationBucket];

// Destination bucket information
rule.destination = destination;

// Prefix matching policy. Policies cannot overlap; otherwise, an error will be returned. The prefix matching root directory is empty
rule.prefix = @"prefix1";
replConfiguration.rule = @[rule];
request.configuation = replConfiguration;

[request setFinishBlock:^(id outputObject, NSError* error) {
// `outputObject` contains all the HTTP response headers
NSDictionary* info = (NSDictionary *) outputObject;

}];
[[QCloudCOSXMLService defaultCOSXML] PutBucketRelication:request];
Note:
For the complete sample, go to GitHub.
Swift
let putBucketReplication = QCloudPutBucketReplicationRequest.init();

// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
putBucketReplication.bucket = "examplebucket-1250000000";

// All cross-region replication configuration information
let config = QCloudBucketReplicationConfiguation.init();
config.role = "qcs::cam::uin/100000000001:uin/100000000001";

// Initiator ID
let rule = QCloudBucketReplicationRule.init();

// Identify the name of a specific rule
rule.identifier = "rule1";
// Indicate whether the rule is enabled. Valid values: .enabled, .disabled
rule.status = .enabled;

// Destination bucket information
let destination = QCloudBucketReplicationDestination.init();
let destinationBucket = "destinationbucket-1250000000";
let region = "ap-beijing";
destination.bucket = "qcs::cos:\\(region)::\\(destinationBucket)";
rule.destination = destination;

// Prefix matching policy. Policies cannot overlap; otherwise, an error will be returned. The prefix matching root directory is empty
rule.prefix = "dir/";

config.rule = [rule];

putBucketReplication.configuation = config;

putBucketReplication.finishBlock = {(result,error) in
if let result = result {
// "result" contains response headers.
} else {
print(error!);
}
}
QCloudCOSXMLService.defaultCOSXML().putBucketRelication(putBucketReplication);
Note:
For the complete sample, go to GitHub.

Querying Cross-region Replication Rules

Description

This API is used to query the cross-region replication rules of a specified bucket.

Sample code

Objective-C
QCloudGetBucketReplicationRequest* request = [[QCloudGetBucketReplicationRequest alloc] init];

// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
request.bucket = @"examplebucket-1250000000";

[request setFinishBlock:^(QCloudBucketReplicationConfiguation* result,
NSError* error) {
// Specific configuration information. A maximum of 1,000 rules are supported. All rules must be directed to one destination bucket.
NSArray *rules = result.rule;
}];
[[QCloudCOSXMLService defaultCOSXML] GetBucketReplication:request];
Note:
For the complete sample, go to GitHub.
Swift
let getBucketReplication = QCloudGetBucketReplicationRequest.init();
getBucketReplication.bucket = "examplebucket-1250000000";
getBucketReplication.setFinish { (config, error) in
if let config = config {
// List all the rules
let rule = config.rule
} else {
print(error!);
}
}
QCloudCOSXMLService.defaultCOSXML().getBucketReplication(getBucketReplication);
Note:
For the complete sample, go to GitHub.

Deleting Cross-region Replication Rules

Description

This API is used to delete the cross-region replication rules of a specified bucket.

Sample code

Objective-C
QCloudDeleteBucketReplicationRequest* request =
[[QCloudDeleteBucketReplicationRequest alloc] init];

// Bucket name in the format of BucketName-Appid, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
request.bucket = @"examplebucket-1250000000";

[request setFinishBlock:^(id outputObject, NSError* error) {
// `outputObject` contains all the HTTP response headers
NSDictionary* info = (NSDictionary *) outputObject;

}];
[[QCloudCOSXMLService defaultCOSXML] DeleteBucketReplication:request];
Note:
For the complete sample, go to GitHub.
Swift
let deleteBucketReplication = QCloudDeleteBucketReplicationRequest.init();
deleteBucketReplication.bucket = "examplebucket-1250000000";
deleteBucketReplication.finishBlock = {(result,error) in
if let result = result {
// "result" contains response headers.
} else {
print(error!);
}
}
QCloudCOSXMLService.defaultCOSXML().deleteBucketReplication(deleteBucketReplication);
Note:
For the complete sample, go to GitHub.

Ajuda e Suporte

Esta página foi útil?

comentários