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