最近更新时间:2026-04-16 20:57:04
public void putBucketQuota() {
// 初始化 Ks3Client,参见“初始化”文档
Ks3Client ks3Client = initKs3Client();
try {
// 设置桶存储配额为 1000 GB
BucketQuota bucketQuota = new BucketQuota(1000L * 1024 * 1024 * 1024);
// 设置日配额
TransferQuota dailyQuota = new TransferQuota();
dailyQuota.setIntranetFlowUp(100L * 1024 * 1024 * 1024); // 设置内网上传流量配额: 100 GB
dailyQuota.setIntranetFlowDown(500L * 1024 * 1024 * 1024); // 设置内网下载流量配额: 500 GB
dailyQuota.setExtranetFlowUp(10L * 1024 * 1024 * 1024); // 设置外网上传流量配额: 10 GB
dailyQuota.setExtranetFlowDown(50L * 1024 * 1024 * 1024); // 设置外网下载流量配额: 50 GB
dailyQuota.setCdnFlowUp(900L * 1024 * 1024 * 1024); // 设置 CDN 上传流量配额:900GB
dailyQuota.setCdnFlowDown(1000L * 1024 * 1024 * 1024); // 设置CDN下载流量配额: 1000 GB
dailyQuota.setGetRequests(10000L); // 设置GET请求配额
dailyQuota.setPutRequests(5000L); // 设置PUT请求配额
dailyQuota.setListRequests(2000L); // 设置LIST请求配额
bucketQuota.setDailyQuota(dailyQuota);
// 设置月配额
TransferQuota monthlyQuota = new TransferQuota();
monthlyQuota.setIntranetFlowUp(1000L * 1024 * 1024 * 1024); // 设置内网上传流量配额: 1000 GB
monthlyQuota.setIntranetFlowDown(5000L * 1024 * 1024 * 1024); // 设置内网下载流量配额: 5000 GB
monthlyQuota.setExtranetFlowUp(100L * 1024 * 1024 * 1024); // 设置外网上传流量配额: 100 GB
monthlyQuota.setExtranetFlowDown(500L * 1024 * 1024 * 1024); // 设置外网下载流量配额: 500 GB
monthlyQuota.setCdnFlowUp(9000L * 1024 * 1024 * 1024); // 设置 CDN 上传流量配额:9000GB
monthlyQuota.setCdnFlowDown(10000L * 1024 * 1024 * 1024L); // 设置CDN下载流量配额: 10000 GB
monthlyQuota.setGetRequests(1000000L); // 设置GET请求配额
monthlyQuota.setPutRequests(500000L); // 设置PUT请求配额
monthlyQuota.setListRequests(200000L); // 设置LIST请求配额
bucketQuota.setMonthlyQuota(monthlyQuota);
ks3Client.putBucketQuota("bucketName", bucketQuota);
} 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();
}
}关于设置存储空间配额相关的API请参见文档:点击查看。
public void getBucketQuota() {
// 初始化 Ks3Client,参见“初始化”文档
Ks3Client ks3Client = initKs3Client();
try {
// 查询桶配额
BucketQuota quota = ks3Client.getBucketQuota("bucketName");
System.out.println("Bucket Storage Quota: " + quota);
TransferQuota dailyQuota = quota.getDailyQuota();
if (dailyQuota != null) {
System.out.println("Daily Quota");
System.out.println(" Intranet Flow Up (bytes): " + dailyQuota.getIntranetFlowUp());
System.out.println(" Intranet Flow Down (bytes): " + dailyQuota.getIntranetFlowDown());
System.out.println(" Extranet Flow Up (bytes): " + dailyQuota.getExtranetFlowUp());
System.out.println(" Extranet Flow Down (bytes): " + dailyQuota.getExtranetFlowDown());
System.out.println(" CDN Flow Up (bytes): " + dailyQuota.getCdnFlowUp());
System.out.println(" CDN Flow Down (bytes): " + dailyQuota.getCdnFlowDown());
System.out.println(" GET Requests: " + dailyQuota.getGetRequests());
System.out.println(" PUT Requests: " + dailyQuota.getPutRequests());
System.out.println(" LIST Requests: " + dailyQuota.getListRequests());
}
TransferQuota monthlyQuota = quota.getMonthlyQuota();
if (monthlyQuota != null) {
System.out.println("Monthly Quota");
System.out.println(" Intranet Flow Up (bytes): " + monthlyQuota.getIntranetFlowUp());
System.out.println(" Intranet Flow Down (bytes): " + monthlyQuota.getIntranetFlowDown());
System.out.println(" Extranet Flow Up (bytes): " + monthlyQuota.getExtranetFlowUp());
System.out.println(" Extranet Flow Down (bytes): " + monthlyQuota.getExtranetFlowDown());
System.out.println(" CDN Flow Up (bytes): " + monthlyQuota.getCdnFlowUp());
System.out.println(" CDN Flow Down (bytes): " + monthlyQuota.getCdnFlowDown());
System.out.println(" GET Requests: " + monthlyQuota.getGetRequests());
System.out.println(" PUT Requests: " + monthlyQuota.getPutRequests());
System.out.println(" LIST Requests: " + monthlyQuota.getListRequests());
}
} 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();
}
}关于获取存储空间配额相关的API请参见文档:点击查看。
public void deleteBucketQuota() {
// 初始化 Ks3Client,参见“初始化”文档
Ks3Client ks3Client = initKs3Client();
try {
// 删除桶配额
ks3Client.deleteBucketQuota("bucketName");
} 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();
}
}关于删除存储空间配额相关的API请参见文档:点击查看。
纯净模式
