Adds a set of tags to an existing S3 object. This example adds tags to the object named "starfish.jpg" located in the bucket "chilkat100".
curl -X PUT https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging \
-d '<Tagging>
<TagSet>
<Tag>
<Key>animal</Key>
<Value>starfish</Value>
</Tag>
</TagSet>
</Tagging>'
var
rest: TChilkatRest;
success: Integer;
authAws: TChilkatAuthAws;
bTls: Integer;
port: Integer;
bAutoReconnect: Integer;
xml: TChilkatXml;
sbRequestBody: TChilkatStringBuilder;
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;
// See the Online Tool for Generating XML Creation Code
xml := TChilkatXml.Create(Self);
xml.Tag := 'Tagging';
xml.UpdateChildContent('TagSet|Tag|Key','animal');
xml.UpdateChildContent('TagSet|Tag|Value','starfish');
sbRequestBody := TChilkatStringBuilder.Create(Self);
xml.GetXmlSb(sbRequestBody.ControlInterface);
sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestSb('PUT','/starfish.jpg?tagging',sbRequestBody.ControlInterface,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;