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>'
<?php
$rest = new COM("Chilkat_9_5_0.Rest");
$authAws = new COM("Chilkat_9_5_0.AuthAws");
$authAws->AccessKey = 'AWS_ACCESS_KEY';
$authAws->SecretKey = 'AWS_SECRET_KEY';
$authAws->Region = 'us-east-1';
$authAws->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->ConnectFailReason . "\n";
print $rest->LastErrorText . "\n";
exit;
}
// See the Online Tool for Generating XML Creation Code
$xml = new COM("Chilkat_9_5_0.Xml");
$xml->Tag = 'Tagging';
$xml->UpdateChildContent('TagSet|Tag|Key','animal');
$xml->UpdateChildContent('TagSet|Tag|Value','starfish');
$sbRequestBody = new COM("Chilkat_9_5_0.StringBuilder");
$xml->GetXmlSb($sbRequestBody);
$sbResponseBody = new COM("Chilkat_9_5_0.StringBuilder");
$success = $rest->FullRequestSb('PUT','/starfish.jpg?tagging',$sbRequestBody,$sbResponseBody);
if ($success != 1) {
print $rest->LastErrorText . "\n";
exit;
}
$respStatusCode = $rest->ResponseStatusCode;
if ($respStatusCode >= 400) {
print 'Response Status Code = ' . $respStatusCode . "\n";
print 'Response Header:' . "\n";
print $rest->ResponseHeader . "\n";
print 'Response Body:' . "\n";
print $sbResponseBody->getAsString() . "\n";
exit;
}
?>