Change file storage class
Updated at:2025-11-03
Change file storage class
As mentioned above, BOS supports three storage classes for files: STANDARD (standard storage), STANDARD_IA (infrequent access storage), and COLD (cold storage). Meanwhile, the BOS C SDK also allows users to perform operations to change the storage class of specific files. The relevant parameters are as follows:
| Parameters | Description |
|---|---|
| x-bce-storage-class | Define the object's storage class. STANDARD_IA indicates infrequent access storage, COLD indicates cold storage, and if no class is specified, the default is standard storage. |
An example is as follows:
C
1 bos_str_set(&object, TEST_OBJECT_NAME1);
2 bos_copy_object_params_t *params = NULL;
3 params = bos_create_copy_object_params(p);
4 bos_table_t *headers = bos_table_make(p, 2);
5 apr_table_add(headers, "x-bce-metadata-directive", "replace");
6 //apr_table_add(headers, "x-bce-storage-class", "ARCHIVE");
7 apr_table_add(headers, "x-bce-storage-class", "STANDARD_IA");
8 s = bos_copy_object(options, &bucket, &object, &bucket, &object, headers, &root, &resp_headers);
9 if (bos_status_is_ok(s)) {
10 printf("put object copy succeeded\n");
11 } else {
12 printf("put object copy failed\n");
13 }
