Sample code for 30+ languages & platforms
C

S3 List Buckets

See more Amazon S3 Examples

Demonstrates how to retrieve the XML listing the buckets for an Amazon S3 account.

Chilkat C Downloads

C
#include <C_CkHttp.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    const char *xmlStr;

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

    http = CkHttp_Create();

    //  Insert your access key here:
    CkHttp_putAwsAccessKey(http,"AWS_ACCESS_KEY");

    //  Insert your secret key here:
    CkHttp_putAwsSecretKey(http,"AWS_SECRET_KEY");

    xmlStr = CkHttp_s3_ListBuckets(http);

    if (CkHttp_getLastMethodSuccess(http) != TRUE) {
        //  Failed
        printf("%s\n",CkHttp_lastErrorText(http));
    }
    else {
        //  Success.  Show the XML response.  (Use the online tool at the link below to generate parsing code.)
        printf("%s\n",xmlStr);
    }

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


    CkHttp_Dispose(http);

    }