(Swift) Generate S3 Signed URL
Demonstrates how to generate a pre-signed S3 URL. Note: This example requires Chilkat v11.0.0 or greater.
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
// Insert your access key here:
http.awsAccessKey = "AWS_ACCESS_KEY"
// Insert your secret key here:
http.awsSecretKey = "AWS_SECRET_KEY"
http.awsRegion = "us-west-2"
http.awsEndpoint = "s3-us-west-2.amazonaws.com"
var bucketName: String? = "chilkattest"
var path: String? = "starfish.jpg"
var signedUrl: String? = http.s3_GenPresignedUrl("GET", useHttps: true, bucketName: bucketName, path: path, numSecondsValid: 3600, awsService: "s3")
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
print("\(signedUrl!)")
}
|