最近更新时间:2025-09-29 16:30:54
以下代码用于设置存储空间传输加速状态:
public void putBucketTransferAcceleration() {
// 初始化 Ks3Client,参见“初始化”文档
Ks3Client ks3Client = initKs3Client();
try {
// 发起请求,开启存储空间的传输加速,false 表示关闭传输加速
ks3Client.putBucketTransferAcceleration("bucketName", true);
} 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 getBucketTransferAcceleration() {
// 初始化 Ks3Client,参见“初始化”文档
Ks3Client ks3Client = initKs3Client();
try {
// 获取存储空间的传输加速状态
TransferAcceleration transferAcceleration = ks3Client.getBucketTransferAcceleration("bucketName");
System.out.println("enabled: " + transferAcceleration.isEnabled());
} 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();
}
}
纯净模式
