You must restore an Archive or a Cold Archive object before you can read it. This topic describes how to restore an Archive or a Cold Archive object.

Notice Do not call RestoreObject to restore an object whose storage class is not Archive or Cold Archive.

Restoration

If you want to read an Archive object or a Cold Archive object, you must restore the object in advance. It takes several minutes to restore an Archive object and takes several hours to restore a Cold Archive object.

The following section describes the status of an Archive object or a Cold Archive object throughout the restoration process:
  1. By default, an Archive object is in the frozen state before restoration.
  2. After you submit a restore request, the object is in the restoring state.
  3. After the server completes the restore task, the object enters the restored state and you can read the object.

    For Archive objects, the restored state lasts 24 hours by default. During the 24 hours, if you call RestoreObject again, the restored state is extended by 24 hours. You can prolong the restored state up to seven days by calling RestoreObject six times during the first 24 hours of restored state. You can also configure the duration of the restored in days by calling RestoreObject once. You can specify a duration of at most seven days.

    For Cold Archive objects, you can specify the duration of restored state and restoration priority. The duration of the restored state must be at least one day and at most seven days. The time required to restore a Cold Archive object to the readable state is determined based on the restoration priority of the object:
    • Expedited: The object is restored within one hour.
    • Standard: The object is restored within two to five hours. If the JobParameters element is not passed in, the default restoration priority is Standard.
    • Bulk: The object is restored within five to twelve hours.
  4. After the restored state expires, the object returns to the frozen state.

Restore Archive objects

The following code provides an example on how to restore an Archive object:

const OSS = require('ali-oss')

const client = new OSS({
  // Set yourRegion to the endpoint of the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set yourRegion to oss-cn-hangzhou. 
  region: 'yourRegion',
  // Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to access OSS because the account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. 
  accessKeyId: 'yourAccessKeyId',
  accessKeySecret: 'yourAccessKeySecret',
  // Specify the name of the bucket. Example: examplebucket. 
  bucket: 'examplebucket',
});

// Specify the name of the object. Example: exampleobject.txt. 
client.restore('exampleobject.txt').then((res) => {
    console.log(res);
}).catch(err => {
    console.log(err);
})

Restore a Cold Archive object

The following code provides an example on how to restore a Cold Archive object:

const OSS = require('ali-oss')

const client = new OSS({
  // Set yourRegion to the endpoint of the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set yourRegion to oss-cn-hangzhou. 
  region: 'yourRegion',
  // Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to access OSS because the account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. 
  accessKeyId: 'yourAccessKeyId',
  accessKeySecret: 'yourAccessKeySecret',
  // Specify the name of the bucket. Example: examplebucket. 
  bucket: 'examplebucket',
});
// Specify the name of the object. Example: exampleobject.txt. 
client.restore('exampleobject.txt',{type:'ColdArchive'})
  .then(res=>console.log(res))
  .catch(e=>console.log(e))

// Set type to the Cold Archive storage class. 
// Set JobParameters to the restoration priority of the object. 
// Expedited: The object is restored within one hour. 
// Standard: The object is restored within two to five hours. If the JobParameters element is not passed in, the default restoration priority is Standard. 
// Bulk: The object is restored within five to twelve hours. 
// Days is used to specify the duration in which the object can remain in the restored state. Unit: days Valid values: 1 to 7. 
//const result = await client.restore('exampleobject.txt',{type:'ColdArchive',JobParameters:'Standard',Days:2})
//.then(r=>console.log(r))

References

  • For more information about the complete sample code that is used to restore Archive or Cold Archive objects, visit GitHub.
  • For more information about the API operation that is called to restore Archive or Cold Archive objects, see RestoreObject.