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