tencent cloud

Feedback

Guetzli Compression

Last updated: 2024-02-02 15:51:37

    Overview

    This document provides an overview of APIs and SDK code samples for Guetzli compression.
    API
    Description
    Enabling Guetzli compression
    Enables the Guetzli compression feature for a bucket.
    Querying Guetzli status
    Queries whether the Guetzli compression feature is enabled.
    Disabling Guetzli compression
    Disables the Guetzli compression feature.

    Enabling Guetzli Compression

    Feature description

    This API is used to enable the Guetzli compression feature for a bucket.

    Method prototype

    func (s *CIService) PutGuetzli(ctx context.Context) (*Response, error)

    Sample request

    // `CIURL` is required
    u, _ := url.Parse("https://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com")
    cu, _ := url.Parse("http://examplebucket-1250000000.pic.ap-guangzhou.myqcloud.com")
    b := &cos.BaseURL{BucketURL: u, CIURL: cu}
    c := cos.NewClient(b, &http.Client{
    Transport: &cos.AuthorizationTransport{
    SecretID: os.Getenv("SECRETID"),
    SecretKey: os.Getenv("SECRETKEY"),
    },
    })
    
    _, err := c.CI.PutGuetzli(context.Background())
    log_status(err)

    Querying Guetzli Status

    Feature description

    This API is used to query whether the Guetzli compression feature is enabled.

    Method prototype

    func (s *CIService) GetGuetzli(ctx context.Context) (*GetGuetzliResult, *Response, error)

    Sample request

    // `CIURL` is required
    u, _ := url.Parse("https://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com")
    cu, _ := url.Parse("http://examplebucket-1250000000.pic.ap-guangzhou.myqcloud.com")
    b := &cos.BaseURL{BucketURL: u, CIURL: cu}
    c := cos.NewClient(b, &http.Client{
    Transport: &cos.AuthorizationTransport{
    SecretID: os.Getenv("SECRETID"),
    SecretKey: os.Getenv("SECRETKEY"),
    },
    })
    
    res, _, err := c.CI.GetGuetzli(context.Background())
    if err == nil {
    fmt.Printf("%v\\n", res.GuetzliStatus)
    }

    Response description

    type GetGuetzliResult struct {
    GuetzliStatus string
    }
    Node Name
    Description
    Type
    GuetzliStatus
    Whether to enable the Guetzli compression feature: on or off
    String

    Disabling Guetzli Compression

    This API is used to disable the Guetzli compression feature.

    Method prototype

    func (s *CIService) DeleteGuetzli(ctx context.Context) (*Response, error)

    Sample request

    // `CIURL` is required
    u, _ := url.Parse("https://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com")
    cu, _ := url.Parse("http://examplebucket-1250000000.pic.ap-guangzhou.myqcloud.com")
    b := &cos.BaseURL{BucketURL: u, CIURL: cu}
    c := cos.NewClient(b, &http.Client{
    Transport: &cos.AuthorizationTransport{
    SecretID: os.Getenv("SECRETID"),
    SecretKey: os.Getenv("SECRETKEY"),
    },
    })
    
    _, err := c.CI.DeleteGuetzli(context.Background())
    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