设置Bucket服务端加密
更新时间:2022-09-14
若用户需要开启Bucket服务端加密,则如下代码可以做到:
参数 | 说明 |
---|---|
encryptionAlgorithm | 指定Bucket的服务器端加密类型,当前只支持AES256加密。 |
public void PutBucketEncryptionByEncryption(BosClient client, String bucketName, String encryptionAlgorithm ) {
SetBucketEncryptionRequest setBucketEncryptionRequest = new SetBucketEncryptionRequest();
setBucketEncryptionRequest.setBucketName(bucketName);
BucketEncryption encryption = new BucketEncryption();
encryption.setEncryptionAlgorithm(encryptionAlgorithm);
setBucketEncryptionRequest.setBucketEncryption(encryption);
client.setBucketEncryption(setBucketEncryptionRequest);
}
若用户想查看Bucket服务端加密信息,则如下代码可以做到:
public GetBucketEncryptionResponse GetBucketEncryption(BosClient client, String bucketName) {
GetBucketEncryptionRequest getBucketEncryptionRequest = new GetBucketEncryptionRequest();
getBucketEncryptionRequest.withBucketName(bucketName);
GetBucketEncryptionResponse resp = new GetBucketEncryptionResponse();
resp = client.getBucketEncryption(getBucketEncryptionRequest);
return resp;
}
若用户想删除Bucket服务端加密信息,则如下代码可以做到:
public void DeleteBucketEncryption(BosClient client, String bucketName) {
DeleteBucketEncryptionRequest deleteBucketEncryptionRequest = new DeleteBucketEncryptionRequest();
deleteBucketEncryptionRequest.withBucketName(bucketName);
client.deleteBucketEncryption(deleteBucketEncryptionRequest);
}