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: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
xmlResponse: HCkXml;
Tagging_xmlns: PWideChar;
i: Integer;
count_i: Integer;
tagPath: PWideChar;
Key: PWideChar;
Value: PWideChar;
begin
rest := CkRest_Create();
authAws := CkAuthAws_Create();
CkAuthAws_putAccessKey(authAws,'AWS_ACCESS_KEY');
CkAuthAws_putSecretKey(authAws,'AWS_SECRET_KEY');
CkAuthAws_putRegion(authAws,'us-east-1');
CkAuthAws_putServiceName(authAws,'s3');
CkRest_SetAuthAws(rest,authAws);
// URL: https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging
bTls := True;
port := 443;
bAutoReconnect := True;
success := CkRest_Connect(rest,'chilkat100.s3.amazonaws.com',port,bTls,bAutoReconnect);
if (success <> True) then
begin
Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/starfish.jpg?tagging',sbResponseBody);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
respStatusCode := CkRest_getResponseStatusCode(rest);
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkRest__responseHeader(rest));
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkStringBuilder__getAsString(sbResponseBody));
Exit;
end;
xmlResponse := CkXml_Create();
CkXml_LoadSb(xmlResponse,sbResponseBody,True);
// See the Online Tool for Generating XML Parse Code
Tagging_xmlns := CkXml__getAttrValue(xmlResponse,'xmlns');
i := 0;
count_i := CkXml_NumChildrenHavingTag(xmlResponse,'TagSet|Tag');
while i < count_i do
begin
CkXml_putI(xmlResponse,i);
Key := CkXml__getChildContent(xmlResponse,'TagSet|Tag[i]|Key');
Value := CkXml__getChildContent(xmlResponse,'TagSet|Tag[i]|Value');
i := i + 1;
end;
CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkStringBuilder_Dispose(sbResponseBody);
CkXml_Dispose(xmlResponse);
<?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>