Arşiv, Soğuk Arşiv ve Derin Soğuk Arşiv nesnelerinin okunabilmesi için önce geri yüklenmesi gerekir. Bu konuda Arşiv ve Soğuk Arşiv nesnelerinin nasıl geri yükleneceği açıklanmaktadır.
Notlar
Yalnızca Arşiv, Soğuk Arşiv ve Derin Soğuk Arşiv nesneleri RestoreObject işlemini destekler.
Bu konuda Çin (Hangzhou) bölgesinin genel uç noktası kullanılmaktadır. Aynı bölgedeki diğer Alibaba Cloud hizmetlerinden OSS'e erişmek için dahili uç nokta kullanın. Desteklenen bölgeler ve uç noktalar hakkında daha fazla bilgi için bkz. Bölgeler ve uç noktalar.
Bu konuda bir OSS uç noktası kullanılarak OssClient örneğinin nasıl oluşturulacağı gösterilmektedir. Özel etki alanı kullanma veya Security Token Service (STS) kimlik bilgileriyle kimlik doğrulama gibi alternatif yapılandırmalar için bkz. OssClient oluşturma.
Bir dosyayı geri yüklemek için
oss:RestoreObjectiznine sahip olmanız gerekir. Daha fazla bilgi için bkz. RAM kullanıcıya özel izinler atama.
Arşiv nesnesini geri yükleme
Aşağıdaki kod, bir Arşiv nesnesinin nasıl geri yükleneceğini gösterir:
<?php
if (is_file(__DIR__ . '/../autoload.php')) {
require_once __DIR__ . '/../autoload.php';
}
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
}
use OSS\Credentials\EnvironmentVariableCredentialsProvider;
use OSS\OssClient;
use OSS\CoreOssException;
// Obtain access credentials from environment variables. Before you run this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
$provider = new EnvironmentVariableCredentialsProvider();
// The Endpoint is set to the China (Hangzhou) region. Replace it with the actual Endpoint.
$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
// Specify the bucket name. Example: examplebucket.
$bucket= "examplebucket";
// Specify the full path of the Archive object. Do not include the bucket name. Example: srcexampleobject.txt.
$object = "srcexampleobject.txt";
try {
$config = array(
"provider" => $provider,
"endpoint" => $endpoint,
"signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4,
"region"=> "cn-hangzhou"
);
$ossClient = new OssClient($config);
// Restore the file.
$ossClient->restoreObject($bucket, $object);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
Soğuk Arşiv nesnesini geri yükleme
Aşağıdaki kod, bir Soğuk Arşiv nesnesinin nasıl geri yükleneceğini gösterir:
<?php
if (is_file(__DIR__ . '/../autoload.php')) {
require_once __DIR__ . '/../autoload.php';
}
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
}
use OSS\Credentials\EnvironmentVariableCredentialsProvider;
use OSS\OssClient;
use OSS\CoreOssException;
use OSS\Model\RestoreConfig;
// Obtain access credentials from environment variables. Before you run this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
$provider = new EnvironmentVariableCredentialsProvider();
// The Endpoint is set to the China (Hangzhou) region. Replace it with the actual Endpoint.
$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
// Specify the bucket name. Example: examplebucket.
$bucket= "examplebucket";
// Specify the full path of the Cold Archive object. Do not include the bucket name. Example: srcexampleobject.txt.
$object = "srcexampleobject.txt";
try {
$config = array(
"provider" => $provider,
"endpoint" => $endpoint,
"signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4,
"region"=> "cn-hangzhou"
);
$ossClient = new OssClient($config);
// The number of days for which the object remains in the restored state. Valid values: 1 to 7.
$day = 3;
// The restoration priority. This is set to Bulk, which means the object is restored within 5 to 12 hours.
// To restore the object within 2 to 5 hours, set this parameter to Standard. To restore the object within 1 hour, set this parameter to Expedited.
$tier = "Bulk";
$config = new RestoreConfig($day,$tier);
$options = array(
OssClient::OSS_RESTORE_CONFIG => $config
);
$result = $ossClient->restoreObject($bucket, $object,$options);
} catch (OssException $e) {
printf($e->getMessage() . "\n");
return;
}
İlgili bilgiler
Arşiv ve Soğuk Arşiv dosyalarını geri yüklemek için kullanılan API işlemi hakkında daha fazla bilgi için bkz. RestoreObject.