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.
Sample code
The following 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;
}];
// Implement synchronous blocking to wait for the task to complete.
// [restoreObjectTask waitUntilFinished];
References
For more information about the API operation that you can call to restore Archive objects, see RestoreObject.
For more information about how to initialize an OSSClient instance, see Initialization.