(Lianja) Generate S3 Signed URL
Demonstrates how to generate a pre-signed S3 URL.
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
// Insert your access key here:
loHttp.AwsAccessKey = "ABQXXABC83ABCDEFVQXX"
// Insert your secret key here:
loHttp.AwsSecretKey = "XXXXYYYYabcdABCD12345678xxxxyyyyzzzz"
lcBucketName = "testbucket"
lcPath = "starfish.jpg"
loExpireTime = createobject("CkDateTime")
loExpireTime.SetFromCurrentSystemTime()
llBLocalTime = .F.
// Set the expiration time to 1 hour from the current time.
loExpireTime.SetFromUnixTime(llBLocalTime,loExpireTime.GetAsUnixTime(llBLocalTime) + 3600)
lcSignedUrl = loHttp.S3_GenerateUrl(lcBucketName,lcPath,loExpireTime)
if (loHttp.LastMethodSuccess <> .T.) then
? loHttp.LastErrorText
else
? lcSignedUrl
endif
release loHttp
release loExpireTime
|