• Object Storage Service

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

Copying a Versioning Object

You can call ObsClient.copyObject to pass the version ID (versionId) to copy 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 ***',    

# Set the version ID of the object to be copied.
versionId = 'versionid'
obsClient.copyObject('sourcebucketname', 'sourceobjectkey', 'destbucketname', 'destobjectkey', versionId=versionId)

if resp.status < 300:
    print('requestId:', resp.requestId)
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)