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

Custom Headers

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2025-11-18 16:52:54

Feature Overview

An HTTP header (metadata header) of an object is a string sent by the server over HTTP before it sends HTML data to the browser. By modifying HTTP headers (metadata headers), you can modify how the webpage responds as well as certain configurations, such as caching time. Modifying an object's HTTP headers does not modify the object itself.
Note:
For objects of ARCHIVE and DEEP ARCHIVE, custom headers can only be set during upload. Setting custom headers for objects that have already been uploaded is not supported.

How It Works

1. Log in to the COS console.
2. Click Bucket List on the left sidebar.
3. Locate the bucket where the object resides and click the bucket name.
4. Click File List on the left sidebar.
5. Locate the object for which a header is to be customized and click More > Custom Header in the operation column on the right. To customize headers for multiple objects, select multiple objects and click More Actions > Custom Header on the top.
6. In the pop-up window, select the parameter type of the metadata header to be set, enter the metadata value, and click OK. COS provides the following six types of object HTTP headers for configuration:
HTTP Header
Description
Example
Content-Type
MIME information of the file
image/jpeg
Cache-Control
File caching mechanism
no-cache: Indicates that cache cannot be used directly, but whether the object has been updated must be verified first with the server. If the object has been updated, it indicates that the cache is expired, and the object must be re-downloaded from the server; if the object has not been updated, the cache is not expired, and the local cache will be used.
max-age=200: Indicates the relative expiration time of the cached content, in seconds.
Content-Disposition
Extension of MIME protocol
inline: Directly previews the content of the file.
attachment: Downloads to the specified path in the browser with the original filename.
attachment; filename="FileName": You should download it to the specified path in the browser with a custom filename. FileName defines the name of the file after download, for example, example.jpg. If the attachment name is in Chinese, it needs to be URL encoded, for example, attachment; filename* = UTF-8' '%E4%B8%AD%E6%96%87.txt
Content-Encoding
File encoding format
gzip
Note: If the Content-Encoding in the header has been modified as gzip, but the file has not been compressed with gzip, a decoding error will occur.
Expires
Expiration date of the cache
Wed, 21 Oct 2015 07:28:00 GMT
x-cos-meta-[custom suffix]
User-defined content
x-cos-meta-via: homepage
Note: Header names support only hyphens (-), digits, and English letters (a-z). Uppercase letters in English will be converted to lowercase letters; other characters, including underscores (_), are not supported.

License request example

Assume that a bucket named "examplebucket-1250000000" was created under account APPID 1250000000, and an object "exampleobject.txt" was uploaded to the bucket's root directory.

Non-custom HTTP header of objects

The sample below shows the headers returned for a request to download this object through a browser or client if no custom HTTP headers are specified.

Request

GET /exampleobject.txt HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Fri, 10 Apr 2020 09:35:16 GMT
Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586511316;1586518516&q-key-time=1586511316;1586518516&q-header-list=date;host&q-url-param-list=&q-signature=1bd1898e241fb978df336dc68aaef4c0acae****
Connection: close

Response

HTTP/1.1 200 OK
Content-Type: text/plain
Access-Control-Allow-Origin: *
Last-Modified: Fri, 10 Apr 2020 09:35:05 GMT

Custom HTTP header of objects

Refer to directions to add the following custom header configuration:
Parameter
Value
Content-Type
image/jpeg
Cache-Control
no-cache
Content-Disposition
attachment; filename* = UTF-8' '%E4%B8%AD%E6%96%87.jpeg
x-cos-meta-md5
1234
Then the headers returned for new requests will be as follows:

Request

GET /exampleobject.txt HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Fri, 10 Apr 2020 09:35:16 GMT
Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1586511316;1586518516&q-key-time=1586511316;1586518516&q-header-list=date;host&q-url-param-list=&q-signature=1bd1898e241fb978df336dc68aaef4c0acae****
Connection: close

Response

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Type: image/jpeg
Content-Disposition: attachment; filename* = UTF-8' '%E4%B8%AD%E6%96%87.jpeg
x-cos-meta-md5: 1234
Access-Control-Allow-Origin: *
Last-Modified: Fri, 10 Apr 2020 09:35:05 GMT
It can be seen that when custom headers are used, the response format of the page can be changed.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan