Sample code for 30+ languages & platforms
Swift

Generate S3 Signed URL

See more Amazon S3 Examples

Demonstrates how to generate a pre-signed S3 URL.

Chilkat Swift Downloads

Swift

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(httpVerb: "GET", useHttps: true, bucketName: bucketName, path: path, numSecondsValid: 3600, awsService: "s3")
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    print("\(signedUrl!)")

}