tencent cloud

Cloud Object Storage

Restoring Archived Objects

Download
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-05-09 11:07:54

Introduction

This document provides sample code and a description for restoring archived objects using the JavaScript SDK with COS.

Must-Knows

To download an object, you must have read permission for the target object. When you configure an authorization policy, set the action to cos:PostObjectRestore. For more information on authorization, see the CAM-supported business APIs.

Feature Overview

The POST Object restore API can be used to restore an object that is archived as the archive storage type by COS. The restored readable object is temporary, and you can set the duration for it to remain readable as well as specify when to delete this temporary replica. You can use the Days parameter to set the expiration time of the temporary object. If it exceeds this duration and you have not initiated any copy, extension, or other operations, the temporary object will be automatically deleted by the system. The temporary object is only a replica of the object of the archive storage type, and the archived source object always exists during this period.

Preliminary Preparation

Before you start, ensure that you have completed cross-domain configuration and SDK initialization.

Use Case

cos.restoreObject({
Bucket: 'examplebucket-1250000000', // Enter your own bucket. This is a required field.
Region: 'COS_REGION', // The region where the bucket resides, for example, ap-beijing. This is a required field.
Key: '1.jpg', // The object key stored in the bucket, for example, 1.jpg or a/b/test.txt. This is a required field.
RestoreRequest: {
Days: 1,
CASJobParameters: {
Tier: 'Expedited'
}
},
}, function(err, data) {
console.log(err || data);
});

Parameter Description

Parameter Name
Parameter Description
Type
Required
Bucket
The name of the bucket. The naming format is BucketName-APPID. The bucket name entered here must follow this format.
String
Yes
Region
The region where the bucket is located. For the enumeration values, see Regions and Access Domains.
String
Yes
Key
The object key (name of the Object). It is the unique identifier of an object within a bucket. For details, see Object Overview.
String
Yes
RestoreRequest
Container for data restoration.
Object
Yes
- Days
Expiration time of the temporary replica.
Number
Yes
- CASJobParameters
Restores job parameters.
Object
Yes
- - Tier
When data is being restored, Tier can be specified as one of the three restoration modes provided by COS: Standard (standard retrieval mode, restoration tasks complete within 3 - 5 hours), Expedited (expedited retrieval mode, restoration tasks complete within 1 - 5 minutes), and Bulk (batch retrieval mode, restoration tasks complete within 5 - 12 hours).
String
Yes

Callback function description

function(err, data) { ... }
Parameter Name
Parameter Description
Type
err
The object returned when an error occurs in the request, including network errors and business errors. It is null if the request is successful. For more details, see Error Codes.
Object
- statusCode
HTTP status code returned by the request, for example, 200, 403, 404.
Number
- headers
Header returned by the request
Object
data
The object returned when the request is successful, or null if an error occurs in the request
Object
- statusCode
HTTP status code returned by the request, for example, 200, 403, 404.
Number
- headers
Header returned by the request
Object

API Operations

For API documentation related to the restore archived object interface, see POST Object restore.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan