Returns the tags associated with an object. This example gets the tags for the object named "starfish.jpg" located in the bucket "chilkat100".
curl -X GET https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging
var
rest: TChilkatRest;
success: Integer;
authAws: TChilkatAuthAws;
bTls: Integer;
port: Integer;
bAutoReconnect: Integer;
sbResponseBody: TChilkatStringBuilder;
respStatusCode: Integer;
xmlResponse: TChilkatXml;
Tagging_xmlns: WideString;
i: Integer;
count_i: Integer;
tagPath: WideString;
Key: WideString;
Value: WideString;
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('GET','/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;
xmlResponse := TChilkatXml.Create(Self);
xmlResponse.LoadSb(sbResponseBody.ControlInterface,1);
// See the Online Tool for Generating XML Parse Code
Tagging_xmlns := xmlResponse.GetAttrValue('xmlns');
i := 0;
count_i := xmlResponse.NumChildrenHavingTag('TagSet|Tag');
while i < count_i do
begin
xmlResponse.I := i;
Key := xmlResponse.GetChildContent('TagSet|Tag[i]|Key');
Value := xmlResponse.GetChildContent('TagSet|Tag[i]|Value');
i := i + 1;
end;
<?xml version="1.0" encoding="UTF-8" ?>
<Tagging xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<TagSet>
<Tag>
<Key>habitat</Key>
<Value>ocean</Value>
</Tag>
<Tag>
<Key>phylum</Key>
<Value>Echinodermata</Value>
</Tag>
<Tag>
<Key>animal</Key>
<Value>starfish</Value>
</Tag>
</TagSet>
</Tagging>