Obtaining Customized Metadata
If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see the API Reference
After an object is successfully downloaded, its customized data is returned. Sample code is as follows:
String endPoint = "https://your-endpoint";
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", "objectname");
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", "objectname");
System.out.println(obsObject.getMetadata().getUserMetadata("property"));
obsObject.getObjectContent().close();
Last Article: Rewriting Response Headers
Next Article: Downloading an Archive Object
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.