Sample code for 30+ languages & platforms
Swift

Demonstrate S3_DownloadBytes

Demonstrates how to download a file into memory from the Amazon S3 service.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // This example assumes the Chilkat HTTP API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!

    http.awsAccessKey = "AWS_ACCESS_KEY"
    http.awsSecretKey = "AWS_SECRET_KEY"

    var bucketName: String? = "chilkat.qa"
    var objectName: String? = "images/sea_creatures/starfish.jpg"
    var localFilePath: String? = "qa_output/starfish.jpg"

    var jpgBytes: NSData

    jpgBytes = http.s3_DownloadBytes(bucketName: bucketName, objectName: objectName)
    if http.lastMethodSuccess != true {
        print("\(http.lastErrorText!)")
        return
    }

    print("Download successful.")

    let fac = CkoFileAccess()!
    success = fac.writeEntireFile(path: localFilePath, fileData: jpgBytes)
    print("File saved success = \(success)")

}