Convert the storage class of an object using OSS SDK for Go 2.0
Object Storage Service (OSS) provides the following storage classes to cover various data storage scenarios from hot data to cold data: Standard, Infrequent Access (IA), Archive, Cold Archive, and Deep Cold Archive. In OSS, once an object is created, its content cannot be modified, and you can only convert the storage class of its copy. This topic describes how to use the Copier.Copy or Client.CopyObject methods to create a copy and change its storage class.
Usage notes
-
The sample code in this topic uses the region ID
cn-hangzhouof the China (Hangzhou) region. By default, the public endpoint is used to access resources in a bucket. If you want to access resources in the bucket by using other Alibaba Cloud services in the same region in which the bucket is located, use an internal endpoint. For more information about the regions and endpoints supported by Object Storage Service (OSS), see OSS regions and endpoints. -
In this topic, access credentials are obtained from environment variables. For more information about how to configure access credentials, see Configure access credentials.
-
Changing the storage class of an object requires the
oss:GetObject,oss:PutObject, andoss:RestoreObjectpermissions. For more information, see how to grant a custom policy to RAM users.
Sample code
References
-
For more information about the API operation that you can call to convert the storage class of objects by using the Copier, see Copier.Copy.
-
For more information about the API operation that you can call to convert the storage class of objects by using the CopyObject method, see CopyObject.