Archive, Cold Archive ve Deep Cold Archive nesnelerine erişebilmek için öncelikle bu nesnelerin geri yüklenmesi gerekir. Bu konuda, Archive, Cold Archive ve Deep Cold Archive nesnelerinin nasıl geri yükleneceği açıklanmaktadır.
Notlar
RestoreObjectişlemi yalnızca Archive, Cold Archive ve Deep Cold Archive nesneleri üzerinde çağrılabilir.Bu konuda Çin (Hangzhou) bölgesinin genel uç noktası kullanılmaktadır. OSS ile aynı bölgedeki diğer Alibaba Cloud hizmetlerinden OSS'e erişmek istiyorsanız dahili uç nokta kullanın. OSS bölgeleri ve uç noktaları hakkında daha fazla bilgi için bkz. Bölgeler ve uç noktalar.
Bu konuda erişim kimlik bilgileri ortam değişkenlerinden alınmaktadır. Erişim kimlik bilgilerinin nasıl yapılandırılacağı hakkında daha fazla bilgi için bkz. OSS SDK for Python 1.0 kullanarak erişim kimlik bilgilerini yapılandırma.
Bu konuda, bir OSS uç noktası kullanılarak bir
OSSClientörneğinin oluşturulması gösterilmektedir. Özel etki alanı kullanma veya Security Token Service (STS) kimlik bilgileriyle kimlik doğrulama gibi alternatif yapılandırmalar için bkz. Başlatma.Nesneleri geri yüklemek için
oss:RestoreObjectiznine sahip olmanız gerekir. Daha fazla bilgi için bkz. Özel ilke atama.
Archive nesnesini geri yükleme
Aşağıdaki kod, bir Archive nesnesinin nasıl geri yükleneceğine ilişkin bir örnek sunar:
# -*- coding: utf-8 -*-
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider
from oss2.models import RestoreConfiguration
# Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())
# Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
endpoint = "https://oss-cn-hangzhou.aliyuncs.com"
# Specify the ID of the region that maps to the endpoint. Example: cn-hangzhou. This parameter is required if you use the signature algorithm V4.
region = "cn-hangzhou"
# Specify the name of your bucket.
bucket = oss2.Bucket(auth, endpoint, "yourBucketName", region=region)
# Specify the full path of the Archive object. Do not include the bucket name in the full path.
objectName = 'yourArchiveObjectName'
# Specify the duration for which the object remains in the restored state. Default value: 1. Unit: day. In this example, the duration is 2 days.
days = 2
restore_config = RestoreConfiguration(days=days)
# Initiate a RestoreObject request.
bucket.restore_object(objectName, input=restore_config)
Cold Archive nesnesini geri yükleme
Aşağıdaki kod, bir Cold Archive nesnesinin nasıl geri yükleneceğine ilişkin bir örnek sunar:
# -*- coding: utf-8 -*-
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider
from oss2.models import (RestoreJobParameters,
RestoreConfiguration,
RESTORE_TIER_EXPEDITED,
RESTORE_TIER_STANDARD,
RESTORE_TIER_BULK)
# Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())
# Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
endpoint = "https://oss-cn-hangzhou.aliyuncs.com"
# Specify the ID of the region that maps to the endpoint. Example: cn-hangzhou. This parameter is required if you use the signature algorithm V4.
region = "cn-hangzhou"
# Specify the name of your bucket.
bucket = oss2.Bucket(auth, endpoint, "yourBucketName", region=region)
# Specify the full path of the Deep Cold Archive object. Do not include the bucket name in the full path.
object_name = "yourColdArchiveObjectName"
# Specify the duration for which the object remains in the restored state. Default value: 1. Unit: day. In this example, the duration is 2 days.
days = 2
# Specify the restoration mode. In this example, the restoration mode is RESTORE_TIER_BULK.
# RESTORE_TIER_EXPEDITED: The object is restored within 1 hour.
# RESTORE_TIER_STANDARD: The object is restored within 2 to 5 hours.
# RESTORE_TIER_BULK: The object is restored within 5 to 12 hours.
job_parameters = RestoreJobParameters(RESTORE_TIER_BULK)
restore_config = RestoreConfiguration(days=days, job_parameters=job_parameters)
# Initiate a RestoreObject request.
bucket.restore_object(object_name, input=restore_config)
Deep Cold Archive nesnesini geri yükleme
Aşağıdaki kod, bir Deep Cold Archive nesnesinin nasıl geri yükleneceğine ilişkin bir örnek sunar:
# -*- coding: utf-8 -*-
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider
from oss2.models import (RestoreJobParameters,
RestoreConfiguration,
RESTORE_TIER_EXPEDITED,
RESTORE_TIER_STANDARD)
# Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())
# Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
endpoint = "https://oss-cn-hangzhou.aliyuncs.com"
# Specify the ID of the region that maps to the endpoint. Example: cn-hangzhou. This parameter is required if you use the signature algorithm V4.
region = "cn-hangzhou"
# Specify the name of your bucket.
bucket = oss2.Bucket(auth, endpoint, "yourBucketName", region=region)
# Specify the full path of the Deep Cold Archive object. Do not include the bucket name in the full path.
object_name = "yourDeepColdArchiveObjectName"
# Specify the duration for which the object remains in the restored state. Default value: 1. Unit: day. In this example, the duration is 2 days.
days = 2
# Specify the restoration mode. In this example, the restoration mode is RESTORE_TIER_STANDARD.
# RESTORE_TIER_EXPEDITED: The object is restored within 12 hours.
# RESTORE_TIER_STANDARD: The object is restored within 48 hours.
job_parameters = RestoreJobParameters(RESTORE_TIER_STANDARD)
restore_config = RestoreConfiguration(days=days, job_parameters=job_parameters)
# Initiate a RestoreObject request.
bucket.restore_object(object_name, input=restore_config)
İlgili Konular
Archive, Cold Archive ve Deep Cold Archive nesnelerini geri yüklemek için kullanılan tam örnek kodu görmek üzere GitHub adresini ziyaret edin.
Archive, Cold Archive ve Deep Cold Archive nesnelerini geri yüklemek için çağırabileceğiniz API işlemi hakkında daha fazla bilgi için bkz. RestoreObject.