PUT Bucket notification
API Description
You can use this API to set event notification for a bucket. You will be notified of all specified operations performed on the bucket.
Method Definition
1. ObsClient->setBucketNotification(array $parameter) 2. ObsClient->setBucketNotificationAsync(array $parameter, callable $callback)
Request Parameter
|
Field |
Type |
Optional or Mandatory |
Description |
||
|---|---|---|---|---|---|
|
Bucket |
string |
Mandatory |
Bucket name |
||
|
TopicConfigurations |
indexed array |
Optional |
Event notification setting list of the bucket |
||
|
ID |
string |
Optional |
Event notification setting ID |
||
|
Topic |
string |
Mandatory |
URN of the event notification topic. After detecting a specific event in the bucket, OBS sends a message to the topic. |
||
|
Event |
indexed array of strings |
Mandatory |
Type of events that need to be notified |
||
|
Filter |
indexed array |
Optional |
List of filtering rules |
||
|
Name |
string |
Optional |
Prefix or suffix of object names for filtering. Possible values are:
|
||
|
Value |
string |
Optional |
Keyword of object names for filtering objects by prefix or suffix |
||
Returned Result
|
Field |
Type |
Description |
|---|---|---|
|
HttpStatusCode |
integer |
HTTP status code |
|
Reason |
string |
Reason description |
|
RequestId |
string |
Request ID returned by the OBS server |
Sample Code
try{
$resp = $obsClient -> setBucketNotification([
'Bucket' => 'bucketname',
'TopicConfigurations' => [
[
'ID' => '001',
'Topic' => 'your topic',
'Event' => [ObsClient::ObjectCreatedAll],
'Filter' => [
['Name' => 'prefix', 'Value' => 'smn'],
['Name' => 'suffix', 'Value' => '.jpg']
]
]
]
]);
printf("RequestId:%s\n", $resp['RequestId']);
}catch (Obs\Common\ObsException $obsException){
printf("ExceptionCode:%s\n", $obsException->getExceptionCode());
printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
}
Last Article: DELETE Bucket cors
Next Article: GET Bucket notification
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.