All Products
Search
Document Center

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

Last Updated:Jan 04, 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.

Examples

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.

OSSRestoreObjectRequest *request = [OSSRestoreObjectRequest new];
// Specify the name of the bucket. Example: examplebucket. 
request.bucketName = @"examplebucket";
// Specify the full path of the object. Do not include the bucket name in the full path. Example: exampleobject.txt. 
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;
}];

References

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