(Tcl) Generate S3 Signed URL
Demonstrates how to generate a pre-signed S3 URL.
load ./chilkat.dll
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set http [new_CkHttp]
# Insert your access key here:
CkHttp_put_AwsAccessKey $http "ABQXXABC83ABCDEFVQXX"
# Insert your secret key here:
CkHttp_put_AwsSecretKey $http "XXXXYYYYabcdABCD12345678xxxxyyyyzzzz"
set bucketName "testbucket"
set path "starfish.jpg"
set expireTime [new_CkDateTime]
CkDateTime_SetFromCurrentSystemTime $expireTime
set bLocalTime 0
# Set the expiration time to 1 hour from the current time.
CkDateTime_SetFromUnixTime $expireTime $bLocalTime [expr [CkDateTime_GetAsUnixTime $expireTime $bLocalTime] + 3600]
set signedUrl [CkHttp_s3_GenerateUrl $http $bucketName $path $expireTime]
if {[CkHttp_get_LastMethodSuccess $http] != 1} then {
puts [CkHttp_lastErrorText $http]
} else {
puts "$signedUrl"
}
delete_CkHttp $http
delete_CkDateTime $expireTime
|