• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Android SDK)
  4. Event Notification
  5. Setting Event Notification

Setting Event Notification

You can call ObsClient.setBucketNotification to set event notification for a bucket. Sample code is as follows:

String endPoint = "yourdomainname";
String ak = "*** Provide your Access Key ***";
String sk = "*** Provide your Secret Key ***";
// Create an instance of ObsClient.
ObsClient obsClient = new ObsClient(ak, sk, endPoint);

BucketNotificationConfiguration bucketNotificationConfig = new BucketNotificationConfiguration();
TopicConfiguration config = new TopicConfiguration();
config.setId("id1");
config.setTopic("your topic");
config.getEvents().add("your event");

Filter f = new Filter();
f.getFilterRules().add(new FilterRule("prefix", "smn"));
f.getFilterRules().add(new FilterRule("suffix", ".jpg"));
config.setFilter(f);
bucketNotificationConfig.addTopicConfiguration(config);

obsClient.setBucketNotification("bucketname", bucketNotificationConfig);
// Close obsClient.
obsClient.close();