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 on the OBS Server

Expedited

Data can be restored within 1 to 5 minutes.

ObsClient::RestoreTierExpedited

Standard

Data can be restored within 3 to 5 hours. This is the default option.

ObsClient::RestoreTierStandard

You can call ObsClient->restoreObject to restore an Archive object. Sample code is as follows:

// Import the dependency library.
require 'vendor/autoload.php';
// Import the SDK code library during source code installation.
// require 'obs-autoloader.php';
// Declare the namespace.
use Obs\ObsClient;
// Create an instance of ObsClient.
$obsClient = new ObsClient ( [
       'key' => '*** Provide your Access Key ***',
       'secret' => '*** Provide your Secret Key ***',
       'endpoint' => 'https://your-endpoint'
] );

// Restore an object in the OBS Archive storage class.

$resp = $obsClient -> restoreObject([
       'Bucket' => 'bucketname',
       'Key' => 'objectname',
       'Days' => 1,
       'Tier' => ObsClient::RestoreTierExpedited
]);

printf("RequestId:%s\n", $resp['RequestId']);

// Wait until the object is restored.
sleep(6 * 60);

$resp = $obsClient -> getObject([
       'Bucket' => 'bucketname',
       'Key' => 'objectname'
]);

printf("RequestId:%s\n", $resp['RequestId']);
printf("Object Content:\n");
// Obtain the object content.
echo $resp ['Body'];
  • The object specified in ObsClient->restoreObject must be in the OBS Archive storage class. Otherwise, an error will be reported when you call this API.
  • Use the Days parameter to specify the retention period (from 1 to 30 days) of an object and the Tier parameter to specify the time spent on restoring the object.