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 that you use the bucket inventory feature to list objects in a bucket. 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 SDKs: Compared with ossutil, using OSS SDKs is more complex and requires the ability to read and modify code. The code is compiled and run on the local device. However, OSS SDKs provide better code reusability. In the later part of this topic, a code sample is provided to show how to restore multiple objects at a time by using OSS SDK for Java.
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.