tencent cloud

Feedback

Custom Headers

Last updated: 2022-04-30 19:29:37

    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.

    For example, if the Content-Encoding header is changed to gzip, but the file itself was not compressed using gzip, a decoding error will occur.

    Note:

    Custom headers are not supported for archived objects.

    Directions

    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. Find the object for which to customize a header and click More Actions > Custom Header in the Operation column on its right.

    To customize headers for multiple objects, select multiple objects and click More Actions > Custom Header at 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;max-age=200
    Content-Disposition MIME type extension attachment;filename="fname.ext"
    Content-Encoding File encoding format gzip
    Expires Controls the expiration date of cache Wed, 21 Oct 2015 07:28:00 GMT
    x-cos-meta-[custom suffix] User-defined header x-cos-meta-via: homepage

    Examples

    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.

    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.file.myqcloud.com
    Accept: */*
    

    Response

    HTTP/1.1 200 OK
    Content-Language:zh-CN
    Content-Type: text/plain
    Content-Disposition: attachment; filename*="UTF-8''exampleobject.txt"
    Access-Control-Allow-Origin: *
    Last-Modified: Tue, 11 Jul 2017 15:30:35 GMT 
    

    If you add custom headers as follows:

    then the headers returned for new requests will be as follows:

    Request

    GET /exampleobject.txt HTTP/1.1
    Host: examplebucket-1250000000.file.myqcloud.com
    Accept: */*
    

    Response

    HTTP/1.1 200 OK
    Content-Language:zh-CN
    Cache-Control: no-cache
    Content-Type: image/jpeg
    Content-Disposition: attachment; filename*="abc.txt"
    x-cos-meta-md5: 1234
    Access-Control-Allow-Origin: *
    Last-Modified: Tue, 11 Jul 2017 15:30:35 GMT
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support