tencent cloud

Cloud Object Storage

Restoring Archived Objects

Download
Modo Foco
Tamanho da Fonte
Última atualização: 2026-05-15 15:06:24

Introduction

This document provides sample code and descriptions for restoring archived objects using the COS Android SDK. It covers retrieving and accessing objects of the archive type (POST Object restore).

Must-Knows

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

Related Examples

Feature Name
Description
Example code
Recovering Archived Objects
Restore (thaw) an object of the ARCHIVE or DEEP_ARCHIVE storage class to read its content.

Preliminary Preparation

Creating a CosXmlService

Before calling a COS API, you must first create a CosXmlService instance. For detailed code, see Creating CosXmlService.

Use Cases

// A bucket name consists of bucketname-appid. You must include the appid. You can view bucket names in the COS console. https://console.tencentcloud.com/cos5/bucket
String bucket = "examplebucket-1250000000";
String cosPath = "exampleobject"; // The location identifier of the object in the bucket, i.e., the object key.
RestoreRequest restoreRequest = new RestoreRequest(bucket, cosPath);
restoreRequest.setExpireDays(5); // Retain for 5 days
restoreRequest.setTier(RestoreConfigure.Tier.Standard); // Standard restore mode

cosXmlService.restoreObjectAsync(restoreRequest, new CosXmlResultListener() {
@Override
public void onSuccess(CosXmlRequest request, CosXmlResult result) {
RestoreResult restoreResult = (RestoreResult) result;
}

// If you call the API using kotlin, note that the exception in the callback method must be nullable. Otherwise, the onFail method will not be called, as follows:
// The type of clientException is CosXmlClientException?, and the type of serviceException is CosXmlServiceException?
@Override
public void onFail(CosXmlRequest cosXmlRequest,
@Nullable CosXmlClientException clientException,
@Nullable CosXmlServiceException serviceException) {
if (clientException != null) {
clientException.printStackTrace();
} else {
serviceException.printStackTrace();
}
}
});

SDK API Reference

For detailed parameters and method descriptions of all SDK interfaces, see SDK API Reference.

API Operations

For descriptions of the API interfaces related to restoring archived objects, see the POST Object restore documentation.

Ajuda e Suporte

Esta página foi útil?

comentários