Downloading an Archive Object
If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see the API Reference
If you want to download an Archive object, you need to restore the object first. Two restore options are supported, as described in the following table.
|
Option |
Description |
Value in OBS Android SDK |
|---|---|---|
|
Expedited |
Data can be restored within 1 to 5 minutes. |
RestoreTierEnum.EXPEDITED |
|
Standard |
Data can be restored within 3 to 5 hours. This is the default option. |
RestoreTierEnum.STANDARD |
You can call ObsClient.restoreObject to restore an Archive object. Sample code is as follows:
String endPoint = "https://your-endpoint";
String ak = "*** Provide your Access Key ***";
String sk = "*** Provide your Secret Key ***";
// Create an instance of ObsClient.
final ObsClient obsClient = new ObsClient(ak, sk, endPoint);
RestoreObjectRequest request = new RestoreObjectRequest();
request.setBucketName("bucketname");
request.setObjectKey("objectname");
request.setDays(1);
request.setRestoreTier(RestoreTierEnum.EXPEDITED);
obsClient.restoreObject(request);
// Wait until the object is restored.
Thread.sleep(60 * 6 * 1000);
// Download an object.
ObsObject obsObject = obsClient.getObject("bucketname", "objectname");
obsObject.getObjectContent().close();
- The object specified in ObsClient.restoreObject must be in the OBS Archive storage class. Otherwise, an exception will be thrown when you call this API.
- RestoreObjectRequest.setDays specifies the retention period of restored object, ranging from 1 to 30.
- RestoreObjectRequest.setTier specifies the restore option, which indicates the time spent on restoring an object.
Last Article: Obtaining Customized Metadata
Next Article: Performing a Resumable Download
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.