Object Storage Service (OSS) can encrypt uploaded data on the server. This is called server-side encryption. When you upload data to OSS, OSS encrypts the uploaded data and then persistently stores the encrypted data. When you download data from OSS, OSS decrypts the data and returns the decrypted data. In addition, a header is added to the response to declare that the data is encrypted on the server.
Usage notes
Before you configure server-side encryption, make sure that you are familiar with this feature. For more information, see Server-side encryption.
The sample code in this topic uses the region ID
cn-hangzhoufor the China (Hangzhou) region. By default, a public endpoint is used to access resources in a bucket. If you want to access resources in the bucket from other Alibaba Cloud services in the same region, use an internal endpoint. For more information about OSS regions and endpoints, see Regions and endpoints.To configure server-side encryption for a bucket, you must have the
oss:PutBucketEncryptionpermission. To query the server-side encryption configuration of a bucket, you must have theoss:GetBucketEncryptionpermission. To delete the server-side encryption configuration of a bucket, you must have theoss:DeleteBucketEncryptionpermission. For more information, see Attach a custom policy to a RAM user.
Examples
References
For the complete sample code for server-side encryption, see put_bucket_encryption, get_bucket_encryption, and delete_bucket_encryption.
For more information about the API operation that you can call to configure server-side encryption, see PutBucketEncryption.
For more information about the API operation that you can call to query server-side encryption configurations, see GetBucketEncryption.
For more information about the API operation that you can call to delete server-side encryption configurations, see DeleteBucketEncryption.