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
DokumentasiCloud Object StorageSDK DocumentationJava SDKSetting Access Domain Names (CDN/Global Acceleration)

Setting Access Domain Names (CDN/Global Acceleration)

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2024-02-02 16:51:03

Overview

This document describes how to request the COS service by using a non-default domain name.

Default CDN acceleration domain name

Feature description

After enabling a default CDN acceleration domain name for a bucket through the COS console, you can set the domain name in the SDK code for acceleration. For more information, see Enabling Default CDN Acceleration Domain Names.

Method prototype

void com.qcloud.cos.ClientConfig.setEndPointSuffix(String endPointSuffix)

Sample request

// 1. Use a CDN acceleration domain. COS verification information does not need to be sent.
COSCredentials cred = new AnonymousCOSCredentials();
// 2. Set the region abbreviation for the bucket. For abbreviations of COS regions, visit https://www.tencentcloud.com/document/product/436/6224
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing"));
// HTTPS is recommended.
clientConfig.setHttpProtocol(HttpProtocol.https);
// 3. Set the suffix for the default CDN acceleration domain.
String cdnSuffix = "file.myqcloud.com";
clientConfig.setEndPointSuffix(cdnSuffix);
// 4. Generate a COS client
COSClient cosclient = new COSClient(cred, clientConfig);

Parameter description

Parameter
Description
Type
endPointSuffix
Set the domain suffix to use the CDN acceleration domain name
String

Custom CDN acceleration domain name

Feature description

After setting a custom CDN acceleration domain name for a bucket through the COS console, you can set the domain name in the SDK code for acceleration. For more information, see Enabling Custom Accelerated Domain Name.

Method prototype

void com.qcloud.cos.ClientConfig.setEndpointBuilder(EndpointBuilder endpointBuilder)

Sample request

// 1. Use a CDN acceleration domain. COS verification information does not need to be sent.
COSCredentials cred = new AnonymousCOSCredentials();
// 2. Set the region abbreviation for the bucket. For abbreviations of COS regions, visit https://www.tencentcloud.com/document/product/436/6224
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing"));
// HTTPS is recommended, which requires the custom domain to have the relevant HTTPS certificate.
clientConfig.setHttpProtocol(HttpProtocol.https);
// 3. Set the custom CDN domain name.
// The `get service` request will use this domain, which is fixed.
String serviceApiEndpoint = "service.cos.myqcloud.com";
String cdnEndpoint = "xxx.xxx.com";
UserSpecifiedEndpointBuilder endPointBuilder = new UserSpecifiedEndpointBuilder(cdnEndpoint, serviceApiEndpoint);
clientConfig.setEndpointBuilder(endPointBuilder);
// 4. Generate a COS client
COSClient cosclient = new COSClient(cred, clientConfig);

Parameter description

Parameter
Description
Type
endPointerBuilder
Constructs the custom CDN acceleration domain.
UserSpecifiedEndpointBuilder
UserSpecifiedEndpointBuilder description:
Parameter
Description
Type
generalApiEndpoint
Custom CDN acceleration domain name
String
getServiceApiEndpoint
Fixed to service.cos.myqcloud.com
String

Custom origin server domain name

Feature description

After setting a custom origin server domain for a bucket through the COS console, you can set the domain name in the SDK code to access COS resources. For more information, see Enabling Custom Origin Server Domains.

Method prototype

void com.qcloud.cos.ClientConfig.setEndpointBuilder(EndpointBuilder endpointBuilder)

Sample request

// 1. Initialize user authentication information (secretId, secretKey).
// You can log in to the CAM console to view and manage `secretId` and `secretKey`.
String secretId = "SECRETID";
String secretKey = "SECRETKEY";
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
// 2. Set the region abbreviation for the bucket. For abbreviations of COS regions, visit https://www.tencentcloud.com/document/product/436/6224
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing"));
// HTTPS is recommended.
clientConfig.setHttpProtocol(HttpProtocol.https);
// 3. Set the custom domain name.
// The get service request will use this domain, which is fixed.
String serviceApiEndpoint = "service.cos.myqcloud.com";
String userEndpoint = "xxx.xxx.com";
UserSpecifiedEndpointBuilder endPointBuilder = new UserSpecifiedEndpointBuilder(userEndpoint, serviceApiEndpoint);
clientConfig.setEndpointBuilder(endPointBuilder);
// 4. Generate a COS client
COSClient cosclient = new COSClient(cred, clientConfig);

Parameter description

Parameter
Description
Type
endPointerBuilder
Constructs the custom origin server domain.
UserSpecifiedEndpointBuilder
UserSpecifiedEndpointBuilder description:
Parameter
Description
Type
generalApiEndpoint
Custom origin server domain
String
getServiceApiEndpoint
Fixed to service.cos.myqcloud.com
String

Global acceleration domain name

Feature description

After enabling a global acceleration domain name for a bucket through the COS console, you can set the domain name in the SDK code for global acceleration. For more information, see Overview.

Method prototype

void com.qcloud.cos.ClientConfig.setEndPointSuffix(String endPointSuffix)

Sample request

// 1. Initialize user authentication information (`secretId`, `secretKey`).
// You can log in to the CAM console to view and manage `secretId` and `secretKey`.
String secretId = "SECRETID";
String secretKey = "SECRETKEY";
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
// 2. Set the region abbreviation for the bucket. For abbreviations of COS regions, visit https://www.tencentcloud.com/document/product/436/6224
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing"));
// HTTPS is recommended.
clientConfig.setHttpProtocol(HttpProtocol.https);
// 3. Set the suffix for the global acceleration endpoint.
String cosSuffix = "cos.accelerate.myqcloud.com";
clientConfig.setEndPointSuffix(cosSuffix);
// 4. Generate a COS client
COSClient cosclient = new COSClient(cred, clientConfig);

Parameter description

Parameter
Description
Type
endPointSuffix
Set the domain suffix to use a global acceleration domain name.
String

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan