Delphi ActiveX 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

Delphi ActiveX Example

var
rest: TChilkatRest;
success: Integer;
authAws: TChilkatAuthAws;
bTls: Integer;
port: Integer;
bAutoReconnect: Integer;
sbResponseBody: TChilkatStringBuilder;
respStatusCode: Integer;

begin
rest := TChilkatRest.Create(Self);

authAws := TChilkatAuthAws.Create(Self);
authAws.AccessKey := 'AWS_ACCESS_KEY';
authAws.SecretKey := 'AWS_SECRET_KEY';
authAws.Region := 'us-east-1';
authAws.ServiceName := 's3';
rest.SetAuthAws(authAws.ControlInterface);

//  URL: https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging
bTls := 1;
port := 443;
bAutoReconnect := 1;
success := rest.Connect('chilkat100.s3.amazonaws.com',port,bTls,bAutoReconnect);
if (success <> 1) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(rest.ConnectFailReason));
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestNoBodySb('DELETE','/starfish.jpg?tagging',sbResponseBody.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;
respStatusCode := rest.ResponseStatusCode;
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(rest.ResponseHeader);
    Memo1.Lines.Add('Response Body:');
    Memo1.Lines.Add(sbResponseBody.GetAsString());
    Exit;
  end;