Configuring Bucket Encryption
API Description
You can use this API to configure encryption for a bucket so that objects can be encrypted using the corresponding method before being uploaded to a bucket. Server-side encryption with keys hosted by KMS (SSE-KMS) is currently available.
Method Definition
func (obsClient ObsClient) SetBucketEncryption(input *SetBucketEncryptionInput) (output *BaseModel, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) SetBucketEncryptionWithSignedURL(signedURL string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error)
Request Parameters
| Field | Type | Optional or Mandatory |
|---|---|---|
| input | Mandatory |
Returned Result
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
var obsClient, _ = obs.New(ak, sk, endpoint, obs.WithSignature(obs.SignatureObs)) func main() { input := &obs.SetBucketEncryptionInput{} input.Bucket = "bucketname" // Specify the input encryption algorithm and the corresponding KMS key. input.SSEAlgorithm = "kms" input.KMSMasterKeyID = "your kms key id" output, err := obsClient.SetBucketEncryption(input) if err == nil { fmt.Printf("RequestId:%s\n", output.RequestId) } else { if obsError, ok := err.(obs.ObsError); ok { fmt.Println(obsError.Code) fmt.Println(obsError.Message) } else { fmt.Println(err) } } }
Last Article: Deleting Bucket Tags
Next Article: Obtaining a Bucket's Encryption Configurations
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.