(Go) 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.
http := chilkat.NewHttp()
// Insert your access key here:
http.SetAwsAccessKey("ABQXXABC83ABCDEFVQXX")
// Insert your secret key here:
http.SetAwsSecretKey("XXXXYYYYabcdABCD12345678xxxxyyyyzzzz")
bucketName := "testbucket"
path := "starfish.jpg"
expireTime := chilkat.NewCkDateTime()
expireTime.SetFromCurrentSystemTime()
bLocalTime := false
// Set the expiration time to 1 hour from the current time.
expireTime.SetFromUnixTime(bLocalTime,expireTime.GetAsUnixTime(bLocalTime) + 3600)
var signedUrl *string = new(string)
signedUrl = *http.S3_GenerateUrl(bucketName,path,expireTime)
if http.LastMethodSuccess() != true {
fmt.Println(http.LastErrorText())
}
else {
fmt.Println(*signedUrl)
}
http.DisposeHttp()
expireTime.DisposeCkDateTime()
|