(PureBasic) S3 Download String Object
Demonstrates how to download a text file (i.e. object) from the Amazon S3 service directly into an in-memory string variable.
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 us-east-1 region.
CkHttp::setCkAwsRegion(http, "us-east-1")
bucketName.s = "chilkat-test-bucket"
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
|