• Object Storage Service

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

Copying a Versioning Object

You can call ObsClient.copyObject and of a versioning object by specifying its version ID (versionId). Sample code is as follows:

String endPoint = "yourdomainname";
String ak = "*** Provide your Access Key ***";
String sk = "*** Provide your Secret Key ***";
// Create an instance of ObsClient.
ObsClient obsClient = new ObsClient(ak, sk, endPoint);

CopyObjectRequest request = new CopyObjectRequest();
request.setSourceBucketName("sourebucketname");
request.setSourceObjectKey("sourceobjectkey");
// Set the version ID of the object to be copied.
request.setVersionId("versionid");
request.setDestinationBucketName("destbucketname");
request.setDestinationObjectKey("destobjectkey");
obsClient.copyObject(request);

// Close obsClient.
obsClient.close();