Search in sources :

Example 1 with BucketLoggingConfiguration

use of com.qcloud.cos.model.BucketLoggingConfiguration in project cos-java-sdk-v5 by tencentyun.

the class BucketDemo method SetBucketLogging.

// 开启日志存储
public static void SetBucketLogging() {
    // 1 初始化用户身份信息(appid, secretId, secretKey)
    COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
    // 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
    ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing-1"));
    // 3 生成cos客户端
    COSClient cosclient = new COSClient(cred, clientConfig);
    // bucket名称, 需包含appid
    String bucketName = "examplebucket-1251668577";
    BucketLoggingConfiguration bucketLoggingConfiguration = new BucketLoggingConfiguration();
    // 设置日志存储的 bucket
    bucketLoggingConfiguration.setDestinationBucketName(bucketName);
    // 设置日志存储的前缀
    bucketLoggingConfiguration.setLogFilePrefix("logs/");
    SetBucketLoggingConfigurationRequest setBucketLoggingConfigurationRequest = new SetBucketLoggingConfigurationRequest(bucketName, bucketLoggingConfiguration);
    cosclient.setBucketLoggingConfiguration(setBucketLoggingConfigurationRequest);
}
Also used : COSClient(com.qcloud.cos.COSClient) COSCredentials(com.qcloud.cos.auth.COSCredentials) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) BucketLoggingConfiguration(com.qcloud.cos.model.BucketLoggingConfiguration) BasicCOSCredentials(com.qcloud.cos.auth.BasicCOSCredentials) Region(com.qcloud.cos.region.Region) SetBucketLoggingConfigurationRequest(com.qcloud.cos.model.SetBucketLoggingConfigurationRequest) ClientConfig(com.qcloud.cos.ClientConfig)

Aggregations

COSClient (com.qcloud.cos.COSClient)1 ClientConfig (com.qcloud.cos.ClientConfig)1 BasicCOSCredentials (com.qcloud.cos.auth.BasicCOSCredentials)1 COSCredentials (com.qcloud.cos.auth.COSCredentials)1 BucketLoggingConfiguration (com.qcloud.cos.model.BucketLoggingConfiguration)1 SetBucketLoggingConfigurationRequest (com.qcloud.cos.model.SetBucketLoggingConfigurationRequest)1 Region (com.qcloud.cos.region.Region)1