tencent cloud

Cloud Object Storage

POST Object restore

Download
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-07-03 10:57:31

Introduction

This document provides example code and a description for restoring archived objects in COS using the HarmonyOS SDK. The operation involves retrieving and accessing archived objects (POST Object restore).
API
Operation Name
Operation Description
Recovering Archived Objects
Restores (thaws) an object of the ARCHIVE or DEEP_ARCHIVE storage class so that you can read its content.

Recovering Archived Objects

Feature Overview

Restore (thaw) an object of the ARCHIVE or DEEP_ARCHIVE storage class to read its content.

Example Code

// Bucket name, which is composed of bucketname-appid. You must include the appid. You can view the bucket name in the COS console at https://console.tencentcloud.com/cos5/bucket.
let bucket = "examplebucket-1250000000";
// The location identifier of an object in a bucket, also known as the object key (the object to be restored).
let archiveCosPath = "exampleobject.txt";

let request = new RestoreObjectRequest(bucket, archiveCosPath);
/**
* For ARCHIVE or DEEP_ARCHIVE objects, you must specify the validity period for the restored temporary copy. The value must be an integer between 1 - 365, and the unit is "day".
* You do not need to specify this parameter for Intelligent Tiering Archive Access or DEEP_ARCHIVE objects.
*/
request.days = 1;
/**
* Restore mode. Valid values:
* - Expedited: The expedited retrieval mode. A restore job can be completed within 1 - 5 minutes (only for ARCHIVE/Intelligent Tiering Archive Access objects).
* - Standard: The standard retrieval mode. An ARCHIVE restore job is completed within 3 - 5 hours, and a DEEP_ARCHIVE restore takes 12 - 24 hours.
* - Bulk: The batch retrieval mode. An ARCHIVE restore job is completed within 5 - 12 hours, and a DEEP_ARCHIVE restore takes 24 - 48 hours.
*
* If you do not specify a restore mode, the Standard retrieval mode is used by default.
*/
request.tier = 'Expedited';
try {
let result = await CosXmlBaseService.default().restoreObject(request)
// The result includes http headers and other information.
} catch (e) {
// Exception handling
}

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan