// Sets notification configuration for a given bucket public Task SetBucketNotificAsync(string bucketName, BucketNotification notification) { try { /* * BucketNotification notification = new BucketNotification(); * Arn topicArn = new Arn("aws", "sns", "us-west-1", "412334153608", "topicminio"); * * TopicConfig topicConfiguration = new TopicConfig(topicArn); * List<EventType> events = new List<EventType>() { EventType.ObjectCreatedPut, EventType.ObjectCreatedCopy }; * topicConfiguration.AddEvents(events); * topicConfiguration.AddFilterPrefix("images"); * topicConfiguration.AddFilterSuffix("jpg"); * notification.AddTopic(topicConfiguration); * * QueueConfig queueConfiguration = new QueueConfig("arn:aws:sqs:us-west-1:482314153608:testminioqueue1"); * queueConfiguration.AddEvents(new List<EventType>() { EventType.ObjectCreatedCompleteMultipartUpload * }); * notification.AddQueue(queueConfiguration); */ var task = minio.SetBucketNotificationsAsync(bucketName, notification); return(task); } catch (MinioException e) { throw; } }
/// <summary> /// Sets the notification configuration for this bucket /// </summary> /// <param name="bucketName">Bucket name</param> /// <param name="notification">Notification object with configuration to be set on the server</param> /// <param name="cancellationToken">Optional cancellation token to cancel the operation</param> /// <returns></returns> public async Task SetBucketNotificationsAsync(string bucketName, BucketNotification notification, CancellationToken cancellationToken = default(CancellationToken)) { utils.ValidateBucketName(bucketName); var request = await this.CreateRequest(Method.PUT, bucketName).ConfigureAwait(false); request.AddQueryParameter("notification", ""); var bodyString = notification.ToString(); var body = System.Text.Encoding.UTF8.GetBytes(bodyString); request.AddParameter("application/xml", body, RestSharp.ParameterType.RequestBody); IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false); }
/// <summary> /// Sets the notification configuration for this bucket /// </summary> /// <param name="bucketName">Bucket name</param> /// <param name="notification">Notification object with configuration to be set on the server</param> /// <param name="cancellationToken">Optional cancellation token to cancel the operation</param> /// <returns></returns> public async Task SetBucketNotificationsAsync(string bucketName, BucketNotification notification, CancellationToken cancellationToken = default(CancellationToken)) { utils.ValidateBucketName(bucketName); var request = await this.CreateRequest(HttpMethod.Put, bucketName) .ConfigureAwait(false); request.AddQueryParameter("notification", ""); var bodyString = notification.ToString(); request.AddXmlBody(bodyString); _ = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false); }
internal override HttpRequestMessageBuilder BuildRequest(HttpRequestMessageBuilder requestMessageBuilder) { if (this.BucketNotificationConfiguration == null) { throw new UnexpectedMinioException("Cannot BuildRequest for SetBucketNotificationsArgs. BucketNotification configuration not assigned"); } requestMessageBuilder.AddQueryParameter("notification", ""); BucketNotification bucketNotificationConfiguration = new BucketNotification(); string body = utils.MarshalXML(bucketNotificationConfiguration, "http://s3.amazonaws.com/doc/2006-03-01/"); // Convert string to a byte array byte[] bodyInBytes = Encoding.ASCII.GetBytes(body); requestMessageBuilder.BodyParameters.Add("content-type", "text/xml"); requestMessageBuilder.SetBody(bodyInBytes); return(requestMessageBuilder); }