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>'
#include <CkRestW.h>
#include <CkAuthAwsW.h>
#include <CkXmlW.h>
#include <CkStringBuilderW.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;
}
// See the Online Tool for Generating XML Creation Code
CkXmlW xml;
xml.put_Tag(L"Tagging");
xml.UpdateChildContent(L"TagSet|Tag|Key",L"animal");
xml.UpdateChildContent(L"TagSet|Tag|Value",L"starfish");
CkStringBuilderW sbRequestBody;
xml.GetXmlSb(sbRequestBody);
CkStringBuilderW sbResponseBody;
success = rest.FullRequestSb(L"PUT",L"/starfish.jpg?tagging",sbRequestBody,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;
}
}