All Products
Document Center

Object Storage Service:Convert the storage class of an object

Last Updated:Oct 18, 2023

Object Storage Service (OSS) provides the following storage classes to cover a variety of data storage scenarios from hot data to cold data: Standard, Infrequent Access (IA), Archive, and Cold Archive. This topic describes how to convert the storage class of an object.

Sample code

The following section provides examples on how to convert the storage class of an object.

  • The following code provides an example on how to convert the storage class of an object from Standard or IA to Archive:

    const OSS = require('ali-oss');
    const client = new OSS({
      // Specify the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the region to oss-cn-hangzhou. 
      region: 'yourregion',
      // Obtain access credentials from environment variables. Before you run the sample code, make sure that you have configured environment variables OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET. 
      accessKeyId: process.env.OSS_ACCESS_KEY_ID,
      accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
      // Specify the name of the bucket. 
      bucket: 'yourbucketname'
    const options = {
    client.copy('Objectname','Objectname',options).then((res) => {
    }).catch(err => {


For more information about the API operation that you can call to convert the storage class of an object, see CopyObject.