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

Weak Network Optimization

PDF
Focus Mode
Font Size
Last updated: 2026-02-10 15:58:54

Introduction

This article describes how to access COS using the QUIC protocol via the COS SDK.

Feature Overview

This article describes how to access COS using the QUIC protocol via the COS SDK. For poor network conditions, the COS SDK now supports the QUIC protocol. QUIC is a low-latency, high-reliability communication protocol implemented over UDP, and the current standard HTTP/3 protocol is built upon QUIC. QUIC supports 0-RTT connection establishment and head-of-line blocking-free multiplexing, enabling easier implementation of user-space congestion control on the client side. This maximizes actual data transmission bandwidth utilization and delivers high-quality data communication even in poor network conditions with high packet loss and latency. Additionally, QUIC supports connection migration, ensuring seamless transition and uninterrupted connectivity during frequent network switching on mobile devices.
Therefore, if you are particularly concerned about the success rate and latency of COS operations such as uploads and downloads in poor network conditions, you can access COS using the QUIC protocol.

Prerequisites

Before performing the operations, you need to activate the EdgeOne service and enable the QUIC feature, then add the corresponding COS domain. The detailed steps are as follows:
1. Go to the EdgeOne console to activate. For specific operations, see activate EdgeOne.
2. In the EdgeOne console, click Add Site to add the business acceleration domain. After entering the site, go to Domain Management, and when Add Domain, select COS origin.

3. Enable the QUIC feature in EdgeOne. For details, see Enable HTTP/3 (QUIC).
4. Note the acceleration domain name in Step 2. This domain needs to be configured in the COS SDK later.
Note:
EdgeOne incurs certain fees. For details, see the EdgeOne Billing Overview.

Operation Steps

Step 1: Configure the QUIC Protocol

Android
iOS
1. Add the QUIC library dependency in the app-level build.gradle file (typically under the App module).
Note:
QUIC SDK 1.5.46 has been adapted to support 16 KB page sizes. It is recommended to upgrade.
When upgrading the QUIC SDK, also upgrade the COS SDK version to 5.9.46 or higher; otherwise, compatibility issues may occur.
dependencies {
...
// Add this line
implementation 'com.qcloud.cos:quic:1.5.46'
}
2. Configure custom domain and enable QUIC through CosXmlServiceConfig in the COS SDK.
String region = "ap-beijing"; // Your bucket region
String eoDomain = "exampledomain.com"; // eo acceleration domain

CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
.setRegion(region)
.setHost(eoDomain) // Configure the acceleration domain
.addNoSignHeaders("Host") // When EO forwards requests, the host may change; avoid signing the host here
.enableQuic(true) // Enable QUIC
.builder();

CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig,
credentialProvider);
1. Add the QUIC library dependency in the podfile file.
pod 'QCloudQuic'
2. Configure custom domain and enable QUIC through QCloudServiceConfiguration in the COS SDK.
NSString * eoDomain = @"exampledomain.com";
QCloudServiceConfiguration* configuration = [QCloudServiceConfiguration new];
configuration.enableQuic = YES; // Enable Quic
configuration.appID = @"appId"; // Set the APPId
configuration.signatureProvider = self;
QCloudCOSXMLEndPoint* endpoint = [[QCloudCOSXMLEndPoint alloc] initWithLiteralURL:[NSURL URLWithString:eoDomain]]; // Configure the acceleration domain
endpoint.useHTTPS = YES; // Use HTTPS
configuration.endpoint = endpoint;

Step 2: Configure Protocol Switching in the SDK

To improve the success rate of SDK requests and reduce costs, the SDK provides a configuration method for the protocol switching policy:
Conservative policy: Use the default HTTPS protocol for requests first, and automatically retry with the QUIC protocol upon network failure.
Aggressive policy: Use the QUIC protocol for requests first, and automatically retry with the default HTTPS protocol upon network failure.
Custom policy: The SDK provides a method to configure the network protocol for requests, allowing the logic of request handling and switching to be flexibly controlled at the business layer (for example, automatically switching based on network quality).
If no switching policy is configured, the QUIC protocol from Step 1 will be used to make requests.
Android
iOS
Configure the conservative and aggressive policies via the setNetworkSwitchStrategy method of CosXmlServiceConfig in the COS SDK.
String region = "ap-beijing"; // Your bucket region
String eoDomain = "exampledomain.com"; // eo acceleration domain
// Aggressive policy
CosXmlServiceConfig.RequestNetworkStrategy aggressiveStrategy = CosXmlServiceConfig.RequestNetworkStrategy.Aggressive;
// Conservative policy
CosXmlServiceConfig.RequestNetworkStrategy conservativeStrategy = CosXmlServiceConfig.RequestNetworkStrategy.Conservative;

CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
.setRegion(region)
.setHost(eoDomain) // Configure the acceleration domain
.addNoSignHeaders("Host") // When EO forwards requests, the host may change; avoid signing the host here
.enableQuic(true) // Enable QUIC
.setNetworkSwitchStrategy(aggressiveStrategy) // Configure the switching policy as aggressive policy
//.setNetworkSwitchStrategy(conservativeStrategy) // Configure the switching policy as conservative policy
.builder();

CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig,
credentialProvider);
Configure the custom policy via the setNetworkType method of the request base class CosXmlRequest.
// Any CosXmlRequest supports this method, for example, upload PutObjectRequest, download GetObjectRequest, delete DeleteObjectRequest, etc.
// The following uses upload as an example
PutObjectRequest putRequest = new PutObjectRequest("examplebucket-1250000000", "exampleobject.txt", "Local file path");
// Custom configuration for the QUIC protocol
putRequest.setNetworkType(CosXmlRequest.RequestNetworkType.QUIC);
// Custom configuration for the default HTTPS protocol
// putRequest.setNetworkType(CosXmlRequest.RequestNetworkType.OKHTTP);
// Initialize TransferConfig with the default configuration. If you need to customize it, see the SDK API documentation.
TransferConfig transferConfig = new TransferConfig.Builder().build();
// Initialize TransferManager
TransferManager transferManager = new TransferManager(cosXmlService, transferConfig);
COSXMLUploadTask uploadTask = transferManager.upload(putRequest, null);
Configure the conservative and aggressive policies via the networkStrategy method of QCloudServiceConfiguration in the COS SDK.
NSString * eoDomain = @"exampledomain.com";
QCloudServiceConfiguration* configuration = [QCloudServiceConfiguration new];
configuration.appID = @"appId"; // Set the APPID
configuration.signatureProvider = self;
QCloudCOSXMLEndPoint* endpoint = [[QCloudCOSXMLEndPoint alloc] initWithLiteralURL:[NSURL URLWithString:eoDomain]]; // Set the acceleration domain
endpoint.useHTTPS = YES; // Use https
// Configure the acceleration domain
configuration.endpoint = endpoint;
// Configure the switch policy as the aggressive policy
configuration.networkStrategy = QCloudRequestNetworkStrategyAggressive;
// Configure the switch policy as the conservative policy
// configuration.networkStrategy = QCloudRequestNetworkStrategyConservative;
// Enable QUIC
configuration.enableQuic = YES;
[QCloudCOSXMLService registerDefaultCOSXMLWithConfiguration:configuration];
[QCloudCOSTransferMangerService registerDefaultCOSTransferMangerWithConfiguration:configuration];
Note:
When EO forwards a request, the host changes. When generating a signature, you need to specify that the Host is not included in the signature, as shown below:
- (void) signatureWithFields:(QCloudSignatureFields*)fileds
request:(QCloudBizHTTPRequest*)request
urlRequest:(NSMutableURLRequest*)urlRequst
compelete:(QCloudHTTPAuthentationContinueBlock)continueBlock
{
// Synchronously obtain the temporary key from the backend server. It is strongly recommended to place the logic for obtaining the temporary key here to maximize the availability of the key.
//...
QCloudCredential* credential = [QCloudCredential new];

// Temporary key SecretId
// Replace sercret_id with your SecretId. Log in to the CAM console to view keys: https://console.tencentcloud.com/cam/capi
credential.secretID = @"SECRETID";
// Temporary key SecretKey
// Replace sercret_key with your SecretKey. Log in to the CAM console to view keys: https://console.tencentcloud.com/cam/capi
credential.secretKey = @"SECRETKEY";
// Temporary key Token
// If using a permanent key, you do not need to provide a token. If using a temporary key, you need to provide one. For instructions on generating and using temporary keys, see https://www.tencentcloud.com/document/product/436/14048?from_cn_redirect=1
credential.token = @"TOKEN";
/** It is strongly recommended to use the server time as the start time for the signature to avoid signature errors caused by significant deviations in the user's local device time (parameters startTime and expiredTime are in seconds).
*/
credential.startDate = [NSDate dateWithTimeIntervalSince1970:startTime]; // Unit: seconds
credential.expirationDate = [NSDate dateWithTimeIntervalSince1970:expiredTime]]; // Unit: seconds

QCloudAuthentationV5Creator* creator = [[QCloudAuthentationV5Creator alloc]
initWithCredential:credential];
// Set the headers to be included in the signature, excluding Host.
creator.shouldSignedList = @[@"Cache-Control", @"Content-Disposition", @"Content-Encoding", @"Content-Length", @"Content-MD5", @"Content-Type", @"Expect", @"Expires", @"If-Match" , @"If-Modified-Since" , @"If-None-Match" , @"If-Unmodified-Since" , @"Origin" , @"Range" , @"transfer-encoding",@"Pic-Operations",@"ci-process"];
// Note: Do not perform copy or mutableCopy operations on the URLRequest here.
QCloudSignature *signature = [creator signatureForData:urlRequst];
continueBlock(signature, nil);
}
By setting the endpoint of the base class QCloudAbstractRequest, you can configure a custom domain.
QCloudPutObjectRequest* put = [QCloudPutObjectRequest new];
// Bucket name, which consists of BucketName-Appid, can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket
put.bucket = @"examplebucket-1250000000";
// Object key, which is the full path of the object on COS. If including a directory, the format should be "video/xxx/movie.mp4"
put.object = @"exampleobject";
// File content. You can pass in a variable of type NSData* or NSURL*
put.body = [@"testFileContent" dataUsingEncoding:NSUTF8StringEncoding];
// Custom configuration for the QUIC protocol
put.networkType = QCloudRequestNetworkQuic;
[put setFinishBlock:^(id result, NSError *error) {
// result contains the response header information
// Obtain the file crc64
NSString * crc64 = [[result __originHTTPURLResponse__].allHeaderFields valueForKey:@"x-cos-hash-crc64ecma"];
}];
[[QCloudCOSXMLService defaultCOSXML] PutObject:put];

Example Projects

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback