This topic describes how to restore an archive object.

You must restore an archive object before you can read it. Do not call RestoreObject for non-archive objects.

The state conversion process of an archive object is as follows:

  • The archive object is initially in the frozen state.
  • After you submit it for restoration, the server restores the object. The object is in the restoring state.
    Note Typically, it takes about one minute to restore an archive object.
  • You can read the object after it is restored. The restored state of the object lasts one day by default. You can prolong this period to a maximum of seven days. After this period expires, the object returns to the frozen state.
Use the following code to restore an archive object:
#include <alibabacloud/oss/OssClient.h>
#include <thread>
#include <chrono>
using namespace AlibabaCloud::OSS;

int main(void)
    /* Initialize the OSS account information. */
    std::string AccessKeyId = "yourAccessKeyId";
    std::string AccessKeySecret = "yourAccessKeySecret";
    std::string Endpoint = "yourEndpoint";
    std::string BucketName = "yourBucketName";
    std::string ObjectName = "yourObjectName";

    /* Initialize network resources. */

    ClientConfiguration conf;
    OssClient client(Endpoint, AccessKeyId, AccessKeySecret, conf);
    /* Restore the archive object. */
    auto outcome = client.RestoreObject(BucketName, ObjectName);

    /* Non-archive objects cannot be restored. */
    if (! outcome.isSuccess()) {
        /* Handle exceptions. */
        std::cout << "RestoreObject fail" <<
        ",code:" << outcome.error(). Code() <<
        ",message:" << outcome.error(). Message() <<
        ",requestId:" << outcome.error(). RequestId() << std::endl;
        return -1;
    std::string onGoingRestore("ongoing-request=\"false\"");
    int maxWaitTimeInSeconds = 600;
    while (maxWaitTimeInSeconds > 0)
        auto meta = client.HeadObject(BucketName, ObjectName);

        std::string restoreStatus = meta.result(). HttpMetaData()["x-oss-restore"];
        std::transform(restoreStatus.begin(), restoreStatus.end(), restoreStatus.begin(), ::tolower);
        if (! restoreStatus.empty() &&, onGoingRestore.size(), onGoingRestore)==0) {
            std::cout << " success, restore status:" << restoreStatus << std::endl;
            /* The archive object is restored.*/
        std::cout << " info, WaitTime:" << maxWaitTimeInSeconds
        << "; restore status:" << restoreStatus << std::endl;
    if (maxWaitTimeInSeconds == 0)
        std::cout << "RestoreObject fail, TimeoutException" << std::endl;

    /* Release network resources. */
    return 0;

For more information about archive storage classes, see Introduction to storage classes. For more information about related status codes, see RestoreObject in API Reference.