Sample code for 30+ languages & platforms
PureBasic

S3 Download File

See more Amazon S3 Examples

Demonstrates how to download a file from the Amazon S3 service.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    success.i = 0

    ; This requires 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

    CkHttp::setCkAwsAccessKey(http, "AWS_ACCESS_KEY")
    CkHttp::setCkAwsSecretKey(http, "AWS_SECRET_KEY")
    CkHttp::setCkAwsRegion(http, "us-west-2")
    CkHttp::setCkAwsEndpoint(http, "s3-us-west-2.amazonaws.com")

    bucketName.s = "chilkat.qa"
    objectName.s = "/images/sea_creatures/starfish.jpg"
    localFilePath.s = "qa_output/starfish.jpg"

    success = CkHttp::ckS3_DownloadFile(http,bucketName,objectName,localFilePath)

    If success <> 1
        Debug CkHttp::ckLastErrorText(http)
    Else
        Debug "File downloaded."
    EndIf



    CkHttp::ckDispose(http)


    ProcedureReturn
EndProcedure