All Products
Search
Document Center

Object Storage Service:Restore objects (iOS SDK)

Last Updated:Feb 27, 2026

Archive, Cold Archive, and Deep Cold Archive objects must be restored before you can read them. Use the OSSRestoreObjectRequest class to submit a restore request through the iOS SDK.

Prerequisites

Before you begin, make sure that you have:

  • An OSSClient instance initialized with a custom domain name or Security Token Service (STS). For more information, see Initialization.

Sample code

The following example restores an object named exampleobject.txt in a bucket named examplebucket. The code applies to objects in the Archive, Cold Archive, or Deep Cold Archive storage class.

OSSRestoreObjectRequest *request = [OSSRestoreObjectRequest new];
// Specify the bucket name.
request.bucketName = @"examplebucket";
// Specify the full path of the object. Do not include the bucket name in the full path.
request.objectKey = @"exampleobject.txt";

OSSTask *restoreObjectTask = [client restoreObject:request];
[restoreObjectTask continueWithBlock:^id _Nullable(OSSTask * _Nonnull task) {
    if (!task.error) {
        NSLog(@"restore object success");
    } else {
        NSLog(@"restore object failed, error: %@", task.error);
    }
    return nil;
}];

To block the current thread until the restore task completes, add the following call after you submit the request:

[restoreObjectTask waitUntilFinished];
The asynchronous continueWithBlock: pattern shown above is preferred for iOS applications because it avoids blocking the main thread.

References