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>'
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CkRest rest = new CkRest();
boolean success;
CkAuthAws authAws = new CkAuthAws();
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
boolean bTls = true;
int port = 443;
boolean bAutoReconnect = true;
success = rest.Connect("chilkat100.s3.amazonaws.com",port,bTls,bAutoReconnect);
if (success != true) {
Log.i(TAG, "ConnectFailReason: " + String.valueOf(rest.get_ConnectFailReason()));
Log.i(TAG, rest.lastErrorText());
return;
}
// See the Online Tool for Generating XML Creation Code
CkXml xml = new CkXml();
xml.put_Tag("Tagging");
xml.UpdateChildContent("TagSet|Tag|Key","animal");
xml.UpdateChildContent("TagSet|Tag|Value","starfish");
CkStringBuilder sbRequestBody = new CkStringBuilder();
xml.GetXmlSb(sbRequestBody);
CkStringBuilder sbResponseBody = new CkStringBuilder();
success = rest.FullRequestSb("PUT","/starfish.jpg?tagging",sbRequestBody,sbResponseBody);
if (success != true) {
Log.i(TAG, rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
if (respStatusCode >= 400) {
Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
Log.i(TAG, "Response Header:");
Log.i(TAG, rest.responseHeader());
Log.i(TAG, "Response Body:");
Log.i(TAG, sbResponseBody.getAsString());
return;
}
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}