Truncating an Object
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
You can use ObsClient.truncateObject to truncate files in a parallel file system.
The 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.
ObsClient obsClient = new ObsClient(ak, sk, endPoint);
// Truncate an object.
TruncateObjectRequest request = new TruncateObjectRequest();
request.setBucketName("bucketname");
request.setObjectKey("objectname");
request.setNewLength(1024L);
TruncateObjectResult result = obsClient.truncateObject(request);
- This API is supported only in the parallel file system.
- In this example, the size of the objectname object is changed to 1024 bytes. You can truncate a file to a larger or smaller size. After the file is truncated, the used storage capacity is calculated according to the new size.
Last Article: Renaming an Object
Next Article: Object Upload
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.