Sample code for 30+ languages & platforms
PureBasic

Amazon S3 Download String from Bucket in Region

See more Amazon S3 Examples

Demonstrates how to download a text file (i.e. object) from an S3 bucket NOT in the us-east-1 region.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; Insert your access key here:
    CkHttp::setCkAwsAccessKey(http, "AWS_ACCESS_KEY")

    ; Insert your secret key here:
    CkHttp::setCkAwsSecretKey(http, "AWS_SECRET_KEY")

    ; This bucket is in the eu-central-1 region.
    CkHttp::setCkAwsRegion(http, "eu-central-1")

    bucketName.s = "chilkateufrankfurt"

    objectName.s = "fruit.xml"

    charset.s = "utf-8"

    fileContents.s
    fileContents = CkHttp::ckS3_DownloadString(http,bucketName,objectName,charset)

    If CkHttp::ckLastMethodSuccess(http) <> 1
        ; Failed
        Debug CkHttp::ckLastErrorText(http)
    Else
        ; Success
        Debug fileContents
    EndIf



    CkHttp::ckDispose(http)


    ProcedureReturn
EndProcedure