tencent cloud

masukan

Setting Access Domain Names (CDN/Global Acceleration)

Terakhir diperbarui:2024-02-01 17:32:35

    Overview

    This document describes how to request the COS service using a non-default endpoint.

    SDK API References

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

    Default CDN acceleration domain name

    The sample code below shows how to access a COS service using a default CDN acceleration domain name.

    Sample code

    // The bucket region can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket/. For more information about regions, see https://www.tencentcloud.com/document/product/436/6224.
    String region = "ap-beijing"; // Bucket region
    // Default CDN acceleration domain name of the bucket
    String cdnDomain = "examplebucket-1250000000.file.myqcloud.com";
    
    CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
    .isHttps(true)
    .setRegion(region)
    .setDebuggable(false)
    .setHostFormat(cdnDomain) // Modify the requested domain name
    .addHeader("Host", cdnDomain) // Modify the “Host” filed in the header
    .builder();
    
    // The credentialProvider class is not provided. Instead, you add parameters to the URL when downloading
    // for CDN permission verification
    CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig);
    Note:
    For more samples, please visit GitHub.

    Custom CDN acceleration domain name

    The sample code below shows how to access a COS service using a custom CDN acceleration domain name.

    Sample code

    // The bucket region can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket/. For more information about regions, see https://www.tencentcloud.com/document/product/436/6224.
    String region = "ap-beijing"; // Bucket region
    String cdnCustomDomain = "exampledomain.com"; // Custom CDN acceleration domain name
    
    CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
    .isHttps(true)
    .setRegion(region)
    .setDebuggable(false)
    .setHostFormat(cdnCustomDomain) // Modify the requested domain name
    .addHeader("Host", cdnCustomDomain) // Modify the “Host” filed in the header
    .builder();
    // The credentialProvider class is not provided. Instead, you add parameters to the URL when downloading
    // for CDN permission verification
    CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig);
    Note:
    For more samples, please visit GitHub.

    Custom origin server domain name

    For more information, see Enabling Custom Origin Domain.
    The sample code below shows how to access a COS service using a custom origin server domain name.

    Sample code

    // The bucket region can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket/. For more information about regions, see https://www.tencentcloud.com/document/product/436/6224.
    String region = "ap-beijing"; // Bucket region
    String customDomain = "exampledomain.com"; // Custom origin server domain name
    
    CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
    .isHttps(true)
    .setRegion(region)
    .setDebuggable(false)
    .setHostFormat(customDomain) // Modify the requested domain name
    .builder();
    
    CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig,
    credentialProvider);
    Note:
    For more samples, please visit GitHub.

    Global acceleration endpoint

    For more information on global acceleration, see Overview.
    The sample code below shows how to access a COS service using a global acceleration endpoint.

    Sample code

    // The bucket region can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket/. For more information about regions, see https://www.tencentcloud.com/document/product/436/6224.
    String region = "ap-beijing"; // Bucket region
    
    CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
    .isHttps(true)
    .setRegion(region)
    .setDebuggable(false)
    .setAccelerate(true) // Enable a global acceleration endpoint
    .builder();
    
    CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig,
    credentialProvider);
    Note:
    For more samples, please visit GitHub.
    Hubungi Kami

    Hubungi tim penjualan atau penasihat bisnis kami untuk membantu bisnis Anda.

    Dukungan Teknis

    Buka tiket jika Anda mencari bantuan lebih lanjut. Tiket kami tersedia 7x24.

    Dukungan Telepon 7x24