Sample code for 30+ languages & platforms
Swift

Wasabi Download String

See more Wasabi Examples

Demonstrates how to download a text Wasabi object to a string variable.

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 = "access-key"

    // Insert your secret key here:
    http.awsSecretKey = "secret-key"

    // Use the endpoint matching the bucket's region.
    http.awsEndpoint = "s3.us-west-1.wasabisys.com"

    var bucketName: String? = "chilkattest"
    var objectName: String? = "orchard.json"

    // This is the byte representation of the text file downloaded from Wasabi.
    // It must be specified to allow Chilkat to correctly interpret the bytes as characters.
    var charset: String? = "utf-8"

    var fileContents: String? = http.s3_DownloadString(bucketName: bucketName, objectName: objectName, charset: charset)

    if http.lastMethodSuccess != true {
        print("\(http.lastErrorText!)")
    }
    else {
        print("\(fileContents!)")
        print("Success.")
    }


}