示例#1
0
 static void DeleteBucketNotification()
 {
     try
     {
         NotificationConfiguration    notificationConfig = new NotificationConfiguration();
         SetBucketNotificationRequest request            = new SetBucketNotificationRequest
         {
             BucketName    = bucketName,
             Configuration = notificationConfig
         };
         SetBucketNotificationResponse response = client.SetBucketNotification(request);
         Console.WriteLine("Delete bucket notification  response: {0}", response.StatusCode);
     }
     catch (ObsException ex)
     {
         Console.WriteLine("Exception errorcode: {0}, when delete bucket notification.", ex.ErrorCode);
         Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage);
     }
 }
示例#2
0
        static void SetBucketNotification()
        {
            try
            {
                FilterRule filterRule1 = new FilterRule();
                filterRule1.Name  = FilterNameEnum.Prefix;
                filterRule1.Value = "smn";
                TopicConfiguration topicConfiguration1 = new TopicConfiguration();
                topicConfiguration1.Id    = "Id001";
                topicConfiguration1.Topic = "urn:smn:globrg:35667523534:topic1";
                topicConfiguration1.Events.Add(EventTypeEnum.ObjectCreatedAll);
                topicConfiguration1.FilterRules = new List <FilterRule>();
                topicConfiguration1.FilterRules.Add(filterRule1);

                FilterRule filterRule2 = new FilterRule();
                filterRule2.Name  = FilterNameEnum.Suffix;
                filterRule2.Value = ".jpg";
                TopicConfiguration topicConfiguration2 = new TopicConfiguration();
                topicConfiguration2.Id    = "Id002";
                topicConfiguration2.Topic = "urn:smn:globrg:35667523535:topic2";
                topicConfiguration2.Events.Add(EventTypeEnum.ObjectRemovedAll);
                topicConfiguration2.FilterRules = new List <FilterRule>();
                topicConfiguration2.FilterRules.Add(filterRule2);

                NotificationConfiguration notificationConfiguration = new NotificationConfiguration();
                notificationConfiguration.TopicConfigurations = new List <TopicConfiguration>();
                notificationConfiguration.TopicConfigurations.Add(topicConfiguration1);
                notificationConfiguration.TopicConfigurations.Add(topicConfiguration2);

                SetBucketNotificationRequest request = new SetBucketNotificationRequest
                {
                    BucketName    = bucketName,
                    Configuration = notificationConfiguration,
                };
                SetBucketNotificationResponse response = client.SetBucketNotification(request);
                Console.WriteLine("Set bucket notification response: {0}", response.StatusCode);
            }
            catch (ObsException ex)
            {
                Console.WriteLine("Exception errorcode: {0}, when set bucket notification.", ex.ErrorCode);
                Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage);
            }
        }
示例#3
0
 /// <summary>
 /// 设置桶的消息通知配置。
 /// </summary>
 /// <param name="request">设置桶消息通知配置的请求参数。</param>
 /// <returns>设置桶消息通知配置的响应结果。</returns>
 public SetBucketNotificationResponse SetBucketNotification(SetBucketNotificationRequest request)
 {
     return(this.DoRequest <SetBucketNotificationRequest, SetBucketNotificationResponse>(request));
 }
 /// <summary>
 /// Start the asynchronous request for configuring bucket notification.
 /// </summary>
 /// <param name="request">Parameters in a request for configuring bucket notification</param>
 /// <param name="callback">Asynchronous request callback function</param>
 /// <param name="state">Asynchronous request status object</param>
 /// <returns>Response to the asynchronous request</returns>
 public IAsyncResult BeginSetBucketNotification(SetBucketNotificationRequest request, AsyncCallback callback, object state)
 {
     return(this.BeginDoRequest <SetBucketNotificationRequest>(request, callback, state));
 }