• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (PHP 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:

// Import the third-party open source libraries.
require 'vendor/autoload.php';
// Import the SDK code library.
require 'obs-autoloader.php';
// Declare the namespace.
use Obs\S3\ObsClient;
// Create an instance of ObsClient.
$obsClient = new ObsClient ( [ 
       'key' => '*** Provide your Access Key ***',
       'secret' => '*** Provide your Secret Key ***',
       'endpoint' => 'https://yourdomainname'
] );

$resp = $obsClient->setBucketNotification ( [ 
       'Bucket' => 'bucketname',
       'TopicConfigurations' => [ 
            [
                'ID' => '001',
                'Topic' => 'urn:smn:region:xxxx:topic1',
                'Event' => [ 
                           's3:ObjectCreated:*' 
                ],
                'Filter' => [ 
                       [ 
                                  'Name' => 'prefix',
                                  'Value' => 'smn' 
                       ],
                       [ 
                                  'Name' => 'suffix',
                                  'Value' => '.jpg' 
                       ] 
                ]
           ] 
       ] 
] );
printf ( "RequestId:%s\n", $resp ['RequestId'] );
NOTE:

Use the TopicConfigurations parameter to configure the event notification for a bucket.