Sample code for 30+ languages & platforms
Xbase++

Wasabi List Buckets

See more Wasabi Examples

Demonstrates how to list Wasabi buckets.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL cBucketsXml
LOCAL oXml
LOCAL cName
LOCAL cCreationDate
LOCAL cListAllMyBucketsResult_xmlns
LOCAL cID
LOCAL cDisplayName
LOCAL i
LOCAL nCount_i

nSuccess := 0

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oHttp := CreateObject("Chilkat.Http")

//  Insert your access key here:
oHttp:AwsAccessKey := "access-key"

//  Insert your secret key here:
oHttp:AwsSecretKey := "secret-key"

oHttp:AwsEndpoint := "s3.wasabisys.com"

cBucketsXml := oHttp:S3_ListBuckets()

IF (oHttp:LastMethodSuccess != 1)
    ? oHttp:LastErrorText
    oHttp:destroy()
    RETURN
ENDIF

oXml := CreateObject("Chilkat.Xml")
oXml:LoadXml(cBucketsXml)
? oXml:GetXml()

//  Use this online tool to generate parsing code from sample XML: 
//  Generate Parsing Code from XML

//  Sample output:

//  <?xml version="1.0" encoding="UTF-8"?>
//  <ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
//      <Owner>
//          <ID>1039F31570DBC320E89D391632FCA06FE6D10CBB2ADBD0BF6439BB1DA0C3FAD6</ID>
//          <DisplayName>admin</DisplayName>
//      </Owner>
//      <Buckets>
//          <Bucket>
//              <Name>chilkat</Name>
//              <CreationDate>2021-10-26T12:39:44.000Z</CreationDate>
//          </Bucket>
//          <Bucket>
//              <Name>chilkat-wasabi-testbucket</Name>
//              <CreationDate>2021-10-27T21:07:40.000Z</CreationDate>
//          </Bucket>
//      </Buckets>
//  </ListAllMyBucketsResult>

cListAllMyBucketsResult_xmlns := oXml:GetAttrValue("xmlns")
cID := oXml:GetChildContent("Owner|ID")
cDisplayName := oXml:GetChildContent("Owner|DisplayName")
i := 0
nCount_i := oXml:NumChildrenHavingTag("Buckets|Bucket")
DO WHILE i < nCount_i
    oXml:I := i
    cName := oXml:GetChildContent("Buckets|Bucket[i]|Name")
    cCreationDate := oXml:GetChildContent("Buckets|Bucket[i]|CreationDate")
    i := i + 1
ENDDO

oHttp:destroy()
oXml:destroy()