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
#include <CkRestW.h>
#include <CkAuthAwsW.h>
#include <CkStringBuilderW.h>
#include <CkXmlW.h>
void ChilkatSample(void)
{
CkRestW rest;
bool success;
CkAuthAwsW authAws;
authAws.put_AccessKey(L"AWS_ACCESS_KEY");
authAws.put_SecretKey(L"AWS_SECRET_KEY");
authAws.put_Region(L"us-east-1");
authAws.put_ServiceName(L"s3");
rest.SetAuthAws(authAws);
// URL: https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect(L"chilkat100.s3.amazonaws.com",port,bTls,bAutoReconnect);
if (success != true) {
wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
wprintf(L"%s\n",rest.lastErrorText());
return;
}
CkStringBuilderW sbResponseBody;
success = rest.FullRequestNoBodySb(L"GET",L"/starfish.jpg?tagging",sbResponseBody);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",rest.responseHeader());
wprintf(L"Response Body:\n");
wprintf(L"%s\n",sbResponseBody.getAsString());
return;
}
CkXmlW xmlResponse;
xmlResponse.LoadSb(sbResponseBody,true);
// See the Online Tool for Generating XML Parse Code
const wchar_t *Tagging_xmlns = 0;
int i;
int count_i;
const wchar_t *tagPath = 0;
const wchar_t *Key = 0;
const wchar_t *Value = 0;
Tagging_xmlns = xmlResponse.getAttrValue(L"xmlns");
i = 0;
count_i = xmlResponse.NumChildrenHavingTag(L"TagSet|Tag");
while (i < count_i) {
xmlResponse.put_I(i);
Key = xmlResponse.getChildContent(L"TagSet|Tag[i]|Key");
Value = xmlResponse.getChildContent(L"TagSet|Tag[i]|Value");
i = i + 1;
}
}
<?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>