Sample code for 30+ languages & platforms
Swift

Example: Http.S3_FileExists method

Demonstrates the S3_FileExists method.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    let http = CkoHttp()!

    // Insert your AWS keys here:
    http.awsAccessKey = "AWS_ACCESS_KEY"
    http.awsSecretKey = "AWS_SECRET_KEY"

    var bucketName: String? = "chilkat.ocean"
    var objectName: String? = "seahorse.jpg"
    http.awsRegion = "us-west-2"
    http.awsEndpoint = "s3-us-west-2.amazonaws.com"

    var retval: Int = http.s3_FileExists(bucketName: bucketName, objectName: objectName).intValue
    if retval < 0 {
        print("Failed to check for the S3 object existence")
        print("\(http.lastErrorText!)")
        return
    }

    if retval == 0 {
        print("The S3 object does not exist.")
        return
    }

    print("The S3 object exists.")

}