更新时间:2026-04-28 GMT+08:00
查看事件通知(C SDK)
您可以通过函数get_notification_configuration查看桶的事件通知。
方法定义
void get_notification_configuration(const obs_options *options,
obs_smn_handler *handler, void *callback_data); 参数描述
| 字段名 | 类型 | 约束 | 说明 |
|---|---|---|---|
| options | 请求桶的上下文,配置option(C SDK) | 必选 | 桶参数 |
| handler | obs_smn_handler * | 必选 | 回调函数 |
| callback_data | void * | 可选 | 回调数据 |
回调函数类型obs_smn_handler描述如下表:
| 字段名 | 类型 | 说明 |
|---|---|---|
| response_handler | obs_response_handler | 响应回调函数句柄 |
| get_smn_callback_func | obs_smn_callback * | 获取桶的通知配置回调函数 |
代码示例
static void test_get_notification_configuration()
{
obs_options option;
obs_status ret_status = OBS_STATUS_BUTT;
// 设置option
init_obs_options(&option);
option->bucket_options.hostName = "<your-endpoint>";
option->bucket_options.bucketName = "<Your bucketname>";
// 认证用的ak和sk硬编码到代码中或者明文存储都有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全;本示例以ak和sk保存在环境变量中为例,运行本示例前请先在本地环境中设置环境变量ACCESS_KEY_ID和SECRET_ACCESS_KEY。
// 您可以登录访问管理控制台获取访问密钥AK/SK,获取方式请参见https://support.huaweicloud.com/usermanual-ca/ca_01_0003.html
option.bucket_options.access_key = getenv("ACCESS_KEY_ID");
option.bucket_options.secret_access_key = getenv("SECRET_ACCESS_KEY");
// 设置回调函数
obs_smn_handler notification_handler_info =
{
{&response_properties_callback, &response_complete_callback},
&get_notification_info_callback
};
get_notification_configuration(&option, ¬ification_handler_info, &ret_status);
if (OBS_STATUS_OK == ret_status) {
printf("get_notification_config success.\n");
}
else {
printf("get_notification_config failed(%s).\n", obs_get_status_name(ret_status));
}
} 父主题: 事件通知(C SDK)