If you do not enable real-time access of Archive objects, you can access Archive objects only after you restore them. You can restore only one object each time by using the Object Storage Service (OSS) console. You cannot restore multiple objects in a directory at a time by using the OSS console. To restore multiple objects at a time, you can use other methods. This topic describes how to restore multiple objects at a time.
Solution
To restore multiple objects in a bucket at a time, perform the following steps:
1. List all objects.
We recommend using the bucket inventory feature to list objects in a bucket. This feature allows you to conveniently and efficiently list objects, especially when dealing with large quantities. For more information, see Bucket inventory.
You can also list objects by calling the ListObjects operation. However, the operation generates higher fees than inventory-based listing. For more information, see List objects and API operation calling fees.
2. If you list objects by using the bucket inventory feature, filter objects whose StorageClass is Archive in the returned inventory list and record the full paths of the objects excluding the bucket name.
If you list objects by using OSS SDKs, use the Key and StorageClass combination to obtain the paths of objects and their storage classes. The following sample code returns the path of the "s" object and its storage class.
System.out.println("fileurl"+s.getKey()+"&stu:"+s.getStorageClass());
3. Restore objects in the corresponding paths at a time. You can use one of the following methods to restore multiple objects at a time. For more information, see Restore objects.
ossutil: Compared with the other two methods, ossutil is simpler and more efficient to use, if you are familiar with command line operations.
OSS API: The OSS API does not provide an API operation to restore multiple objects at a time. You must call the RestoreObject operation on each of the objects to restore. You must write code to calculate a signature when you call the operation. We recommend that you use the OSS API when your application requires a high level of customization.
Alibaba Cloud SDK: Compared with ossutil, using OSS SDKs is more complex but provides better code reusability. The disadvantage is that you need to use a compilation tool to run the code on your local device, and you need to have the ability to read and modify code. This document provides a Java example. To view it, see the example below.