All Products
Document Center

Object Storage Service:Restore objects by using OSS SDK for Android

Last Updated:Feb 20, 2024

Archive, Cold Archive, and Deep Cold Archive objects must be restored before they can be read. This topic describes how to restore Archive, Cold Archive, and Deep Cold Archive objects.

Usage notes

  • Before you run the sample code in this topic, you must create an OSSClient instance by using methods such as using a custom domain name or Security Token Service (STS). For more information, see Initialization.


The following sample code provides an example on how to restore an object named exampleobject.txt in a bucket named examplebucket. The storage class of the exampleobject.txt object is Archive, Cold Archive, or Deep Cold Archive.


If you successfully restore an object by using the following sample code, HTTP status code 202 is returned. In this case, a period of time is required to restore the object. For more information, see RestoreObject.

// Restore the object. 
RestoreObjectRequest restore = new RestoreObjectRequest();
// Specify the name of the bucket. Example: examplebucket. 
// Specify the full path of the object. Do not include the bucket name in the full path. Example: exampleobject.txt. 
OSSAsyncTask task = oss.asyncRestoreObject(restore, new OSSCompletedCallback<RestoreObjectRequest,
        RestoreObjectResult>() {
    public void onSuccess(RestoreObjectRequest request, RestoreObjectResult result) {
        Log.i("info", "code::"+result.getStatusCode());


    public void onFailure(RestoreObjectRequest request, ClientException clientException,
                          ServiceException serviceException) {
        Log.e("errorMessage", "error: "+serviceException.getRawMessage());




  • For the complete sample code that is used to restore Archive, Cold Archive, and Deep Cold Archive objects, visit GitHub.

  • For more information about the API operation that you can call to restore Archive, Cold Archive, and Deep Cold Archive objects, see RestoreObject.

  • For more information about how to initialize an OSSClient instance, see Initialization.