• Object Storage Service

  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python 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.




Data can be restored within 1 to 5 minutes.


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


Data can be restored within 5 to 12 hours.

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

# Import the module.
from com.obs.client.obs_client import ObsClient
# Create an instance of ObsClient.
obsClient = ObsClient(
    access_key_id='*** Provide your Access Key ***',    
    secret_access_key='*** Provide your Secret Key ***',    

# Restore a Cold object.
resp = obsClient.restoreObject('bucketname', 'objectkey', days=1, tier='Expedited')
if resp.status < 300:
    print('requestId:', resp.requestId)
    # Wait until the object is restored.
    import time
    time.sleep(60 * 6)
# Download an object.
    resp2 = obsClient.getObject('bucketname', 'objectkey', loadStreamInMemory=True)
    if resp2.status < 300:    
        print('requestId:', resp2.requestId)    
        # Obtain the object content.    
        print('buffer:', resp2.body.buffer)    
        print('errorCode:', resp2.errorCode)
        print('errorMessage:', resp2.errorMessage)
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)
  • The object specified in ObsClient.restoreObject must be in the OBS Cold storage class. Otherwise, an error will be reported when you call this API.
  • Use the days parameter to specify the retention period of to-be-restored objects, the parameter value ranges from 1 to 30. Use the tier parameter to specify the restore option that indicates the time consumed for restoring objects.