变更文件存储等级
更新时间:2022-10-08
变更文件存储等级
上文中已提到,BOS支持为文件赋予STANDARD(标准存储), STANDARD_IA(低频存储)和COLD(冷存储)三种存储类型。同时,BOS C++ SDK也支持用户对特定文件执行存储类型变更的操作。 涉及到的参数如下:
参数 | 说明 |
---|---|
x-bce-storage-class | 指定Object的存储类型,STANDARD_IA代表低频存储,COLD代表冷存储,不指定时默认是标准存储类型。 |
示例如下:
// 标准存储转为低频存储
CopyObjectRequest copyObjectRequest(destBucketName, destKey, srcBucketName, srcKey);
copyObjectRequest.mutable_meta()->set_storage_class("STANDARD_IA");
CopyObjectResponse copyObjectResponse;
int ret = client.copy_object(copyObjectRequest, ©ObjectResponse);
// 低频存储转为冷存储
CopyObjectRequest copyObjectRequest(destBucketName, destKey, srcBucketName, srcKey);
copyObjectRequest.mutable_meta()->set_storage_class("COLD");
CopyObjectResponse copyObjectResponse;
ret = client.copy_object(copyObjectRequest, ©ObjectResponse);