PowerShell 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

PowerShell Example

[Reflection.Assembly]::LoadFile("C:\myAssemblies\ChilkatDotNet2.dll")

$rest = New-Object Chilkat.Rest

$authAws = New-Object Chilkat.AuthAws
$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
$bTls = $true
$port = 443
$bAutoReconnect = $true
$success = $rest.Connect("chilkat100.s3.amazonaws.com",$port,$bTls,$bAutoReconnect)
if ($success -ne $true) {
    $("ConnectFailReason: " + $rest.ConnectFailReason)
    $($rest.LastErrorText)
    exit
}

$sbResponseBody = New-Object Chilkat.StringBuilder
$success = $rest.FullRequestNoBodySb("DELETE","/starfish.jpg?tagging",$sbResponseBody)
if ($success -ne $true) {
    $($rest.LastErrorText)
    exit
}

$respStatusCode = $rest.ResponseStatusCode
if ($respStatusCode -ge 400) {
    $("Response Status Code = " + $respStatusCode)
    $("Response Header:")
    $($rest.ResponseHeader)
    $("Response Body:")
    $($sbResponseBody.GetAsString())
    exit
}