• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Java SDK)
  4. Object Download
  5. Obtaining Customized Metadata

Obtaining Customized Metadata

After an object is successfully downloaded, its customized data is returned. 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.
final ObsClient obsClient = new ObsClient(ak, sk, endPoint);

// Upload the object and customize the metadata.
PutObjectRequest request = new PutObjectRequest("bucketname", "objectkey");
ObjectMetadata metadata = new ObjectMetadata();
metadata.addUserMetadata("property", "property-value");
request.setMetadata(metadata);
obsClient.putObject(request);

// Download the object and obtain the customized metadata.
ObsObject obsObject = obsClient.getObject("bucketname", "objectkey");
System.out.println(obsObject.getMetadata().getUserMetadata("property"));

obsObject.getObjectContent().close();

// Close obsClient.
obsClient.close();