Tcl 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

Tcl Example


load ./chilkat.dll

set rest [new_CkRest]

set authAws [new_CkAuthAws]

CkAuthAws_put_AccessKey $authAws "AWS_ACCESS_KEY"
CkAuthAws_put_SecretKey $authAws "AWS_SECRET_KEY"
CkAuthAws_put_Region $authAws "us-east-1"
CkAuthAws_put_ServiceName $authAws "s3"
CkRest_SetAuthAws $rest $authAws

#  URL: https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging
set bTls 1
set port 443
set bAutoReconnect 1
set success [CkRest_Connect $rest "chilkat100.s3.amazonaws.com" $port $bTls $bAutoReconnect]
if {[expr $success != 1]} then {
    puts "ConnectFailReason: [CkRest_ConnectFailReason $rest]"
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    exit
}

set sbResponseBody [new_CkStringBuilder]

set success [CkRest_FullRequestNoBodySb $rest "DELETE" "/starfish.jpg?tagging" $sbResponseBody]
if {[expr $success != 1]} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    delete_CkStringBuilder $sbResponseBody
    exit
}

set respStatusCode [CkRest_ResponseStatusCode $rest]
if {[expr $respStatusCode >= 400]} then {
    puts "Response Status Code = $respStatusCode"
    puts "Response Header:"
    puts [CkRest_responseHeader $rest]
    puts "Response Body:"
    puts [CkStringBuilder_getAsString $sbResponseBody]
    delete_CkRest $rest
    delete_CkAuthAws $authAws
    delete_CkStringBuilder $sbResponseBody
    exit
}


delete_CkRest $rest
delete_CkAuthAws $authAws
delete_CkStringBuilder $sbResponseBody