Swift AWS S3: Delete Tags from Object

Back to Index

Deletes the tags associated with an object. This example deletes the tags for the object named "starfish.jpg" located in the bucket "chilkat100". A response status code = 204 is returned for success.

Documentation: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETEtagging.html

CURL Command

curl -X DELETE https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging

Swift Example


func chilkatTest() {
    let rest = CkoRest()
    var success: Bool

    let authAws = CkoAuthAws()
    authAws.AccessKey = "AWS_ACCESS_KEY"
    authAws.SecretKey = "AWS_SECRET_KEY"
    authAws.Region = "us-east-1"
    authAws.ServiceName = "s3"
    rest.SetAuthAws(authAws)

    //  URL: https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging
    var bTls: Bool = true
    var port: Int = 443
    var bAutoReconnect: Bool = true
    success = rest.Connect("chilkat100.s3.amazonaws.com", port: port, tls: bTls, autoReconnect: bAutoReconnect)
    if success != true {
        print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
        print("\(rest.LastErrorText)")
        return
    }

    let sbResponseBody = CkoStringBuilder()
    success = rest.FullRequestNoBodySb("DELETE", uriPath: "/starfish.jpg?tagging", sb: sbResponseBody)
    if success != true {
        print("\(rest.LastErrorText)")
        return
    }

    var respStatusCode: Int = rest.ResponseStatusCode.intValue
    if respStatusCode >= 400 {
        print("Response Status Code = \(respStatusCode)")
        print("Response Header:")
        print("\(rest.ResponseHeader)")
        print("Response Body:")
        print("\(sbResponseBody.GetAsString())")
        return
    }


}