ListObjects Method

Lists the objects in a bucket.

Syntax

int ListObjects();

Remarks

This method lists the objects in the bucket currently selected by Bucket.

Before calling this method, the ObjectPrefix property may be set in order to restrict the results to only the objects whose names begin with a given string. The ObjectDelimiter property can also be used to further tune the results returned. The MaxObjects configuration setting may be used to limit the number of results returned.

Calling this method will fire the ObjectList event once for each object, and will also populate the Objects* properties. It may also fire the PrefixList event, and populate the PrefixCount and Prefix[i] configuration settings, depending on how the properties discussed above are set.

If there are still more objects available to list when this method returns, the ObjectMarker property will be populated. Continue to call this method until ObjectMarker is empty to accumulate all pages of results in the Objects* properties.

Object Hierarchy Traversal

By using the ObjectDelimiter and ObjectPrefix properties in tandem, applications can effectively "traverse" a virtual hierarchy of objects (or object versions) as if it were a filesystem. For example, assume that objects with the following names exist within a bucket:

  • MyCompany/
  • MyCompany/Department1/
  • MyCompany/Department2/
  • MyCompany/Department2/EmployeeA
  • MyCompany/Department2/EmployeeB

With ObjectDelimiter set to /, we can set ObjectPrefix to successively "deeper" values before calling ListObjects or ListVersions for the following effect:

ObjectPrefix Value ObjectDelimiter Value Objects Returned Prefixes Returned
(empty) /(none) MyCompany/
MyCompany/ /MyCompany/ MyCompany/Department1/
MyCompany/Department2/
MyCompany/Department2/ /MyCompany/Department2/
MyCompany/Department2/EmployeeA
MyCompany/Department2/EmployeeB
(none)

Error Handling

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 Qt Edition - Version 20.0 [Build 8265]