• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python SDK)
  4. Versioning Management
  5. Obtaining a Versioning Object

Obtaining a Versioning Object

You can call ObsClient.getObject to pass the version ID (versionId) to obtain a versioning 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 ***',    
    server='yourdomainname'
)

from com.obs.models.get_object_request import GetObjectRequest
# Set versionId to obtain a versioning object.
getObjectRequest = GetObjectRequest()
getObjectRequest.versionId = 'versionid'

resp = obsClient.getObject('bucketname', 'objectkey', loadStreamInMemory=True, getObjectRequest=getObjectRequest)
if resp.status < 300:
    print('requestId:', resp.requestId)
    print('buffer:', resp.body.buffer)
else:
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)
NOTE:

If versionId is None, the object of the latest version will be downloaded, by default.