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. If you want to convert the storage class of an object, you must use the Bucket.CopyObject method to copy the object to create a new object and convert the storage class of the new object.
Sample code
The following code shows how to convert the storage class of an object.
The following code converts the storage class of an object from Standard or Infrequent Access to Archive:
const OSS = require('ali-oss'); const client = new OSS({ // Set region to the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set region to oss-cn-hangzhou. region: 'yourregion', // Obtain access credentials from environment variables. Before you run this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set. accessKeyId: process.env.OSS_ACCESS_KEY_ID, accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET, authorizationV4: true, // Set bucket to the name of your bucket. bucket: 'yourbucketname' }) const options = { headers:{'x-oss-storage-class':'Archive'} } client.copy('Objectname','Objectname',options).then((res) => { console.log(res); }).catch(err => { console.log(err) })
References
For more information, see CopyObject.