(PureBasic) Generate S3 Signed URL
Demonstrates how to generate a pre-signed S3 URL.
IncludeFile "CkDateTime.pb"
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")
bucketName.s = "chilkattest"
path.s = "starfish.jpg"
expireTime.i = CkDateTime::ckCreate()
If expireTime.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkDateTime::ckSetFromCurrentSystemTime(expireTime)
CkDateTime::ckAddSeconds(expireTime,3600)
signedUrl.s = CkHttp::ckS3_GenerateUrl(http,bucketName,path,expireTime)
If CkHttp::ckLastMethodSuccess(http) <> 1
Debug CkHttp::ckLastErrorText(http)
Else
Debug signedUrl
EndIf
CkHttp::ckDispose(http)
CkDateTime::ckDispose(expireTime)
ProcedureReturn
EndProcedure
|