• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Java SDK)
  4. Quick Start
  5. Listing Objects

Listing Objects

After objects are uploaded, you may want to view the objects contained in a bucket. Sample code is as follows:

ObjectListing objectListing = obsClient.listObjects("bucketname");
for(ObsObject obsObject : objectListing.getObjects()){
    System.out.println(" - " + obsObject.getObjectKey() + "  " +  "(size = " + obsObject.getMetadata().getContentLength() + ")");
}
NOTE:
  • When you call ObsClient.listObjects, an instance of ObjectListing will be returned. This instance contains the response of the listObject request. You can use ObjetListing.getObjects to obtain description of all of the listed objects.
  • In the previous sample code, 1000 objects will be listed, by default.
  • For more information, see Listing Objects.