• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Java SDK)
  4. Object Download
  5. Downloading a cold Object

Downloading a cold Object

If you want to download a Cold object, you need to restore the object first. Three restore options are supported, as described in the following table.

Option

Description

Value in OBS Java 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

Bulk

Data can be restored within 5 to 12 hours.

RestoreTierEnum.BULK

You can call ObsClient.restoreObject to restore a Cold object. Sample code is as follows:

String endPoint = "yourdomainname";
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("objectkey");
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", "objectkey");

obsObject.getObjectContent().close();

// Close obsClient.
obsClient.close();
NOTE:
  • The object specified in ObsClient.restoreObject must be in the OBS Cold 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.setRestoreTier specifies the restore option, which indicates the time spent on restoring an object.