文档中心 对象存储(KS3) SDK Java 存储空间(Java) 管理存储空间归档直读配置

管理存储空间归档直读配置

最近更新时间:2026-07-28 15:02:28

设置归档直读配置

以下代码用于设置归档直读配置:

public void putBucketArchiveDirectRead() {
    // 初始化 Ks3Client,参见"初始化"文档
    Ks3Client ks3Client = initKs3Client();

    try {
        String bucketName = "your-bucket-name";

        // 创建归档直读配置
        ArchiveDirectReadConfiguration configuration = new ArchiveDirectReadConfiguration();
        configuration.setEnabled(true);  // true:启用归档直读功能,false:禁用归档直读功能

        // 设置 Bucket 的归档直读配置
        ks3Client.putBucketArchiveDirectRead(bucketName, configuration);

        System.out.println("归档直读配置设置成功");
    } catch (Ks3ServiceException e) {
        System.out.println("Ks3ServiceException occurred, which means the request was made to KS3, but KS3 returned an error response for some reason.");
        System.out.println("Error Message: " + e.getErrorMessage());
        System.out.println("Error Code: " + e.getErrorCode());
        System.out.println("Request ID: " + e.getRequestId());
    } catch (Ks3ClientException e) {
        System.out.println("Ks3ClientException occurred, which means the client encountered an internal error while trying to communicate with KS3.");
        System.out.println("Error Message: " + e.getMessage());
    } finally {
        // 不再使用时,关闭 Ks3Client
        ks3Client.shutdown();
    }
}

获取归档直读配置

以下代码用于获取归档直读配置:

public void getBucketArchiveDirectRead() {
    // 初始化 Ks3Client,参见"初始化"文档
    Ks3Client ks3Client = initKs3Client();

    try {
        String bucketName = "your-bucket-name";

        // 获取 Bucket 的归档直读配置
        ArchiveDirectReadConfiguration archiveDirectReadConfiguration = ks3Client.getBucketArchiveDirectRead(bucketName);
        System.out.println("归档直读配置状态: " + archiveDirectReadConfiguration.getEnabled());
    } catch (Ks3ServiceException e) {
        System.out.println("Ks3ServiceException occurred, which means the request was made to KS3, but KS3 returned an error response for some reason.");
        System.out.println("Error Message: " + e.getErrorMessage());
        System.out.println("Error Code: " + e.getErrorCode());
        System.out.println("Request ID: " + e.getRequestId());
    } catch (Ks3ClientException e) {
        System.out.println("Ks3ClientException occurred, which means the client encountered an internal error while trying to communicate with KS3.");
        System.out.println("Error Message: " + e.getMessage());
    } finally {
        // 不再使用时,关闭 Ks3Client
        ks3Client.shutdown();
    }
}
上一篇:管理账号阻止公网访问配置(Java)
下一篇:管理存储空间 HTTP/2 协议配置
以上内容是否对您有帮助?
有帮助
没帮助