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>'
use chilkat();
$rest = chilkat::CkRest->new();
$authAws = chilkat::CkAuthAws->new();
$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
$bTls = 1;
$port = 443;
$bAutoReconnect = 1;
$success = $rest->Connect("chilkat100.s3.amazonaws.com",$port,$bTls,$bAutoReconnect);
if ($success != 1) {
print "ConnectFailReason: " . $rest->get_ConnectFailReason() . "\r\n";
print $rest->lastErrorText() . "\r\n";
exit;
}
# See the Online Tool for Generating XML Creation Code
$xml = chilkat::CkXml->new();
$xml->put_Tag("Tagging");
$xml->UpdateChildContent("TagSet|Tag|Key","animal");
$xml->UpdateChildContent("TagSet|Tag|Value","starfish");
$sbRequestBody = chilkat::CkStringBuilder->new();
$xml->GetXmlSb($sbRequestBody);
$sbResponseBody = chilkat::CkStringBuilder->new();
$success = $rest->FullRequestSb("PUT","/starfish.jpg?tagging",$sbRequestBody,$sbResponseBody);
if ($success != 1) {
print $rest->lastErrorText() . "\r\n";
exit;
}
$respStatusCode = $rest->get_ResponseStatusCode();
if ($respStatusCode >= 400) {
print "Response Status Code = " . $respStatusCode . "\r\n";
print "Response Header:" . "\r\n";
print $rest->responseHeader() . "\r\n";
print "Response Body:" . "\r\n";
print $sbResponseBody->getAsString() . "\r\n";
exit;
}