All Products
Search
Document Center

ApsaraVideo VOD:Specify multiple callback URLs

Last Updated:Mar 28, 2024

ApsaraVideo VOD provides the HTTP callback feature. You can configure the UserData parameter when you use the ApsaraVideo VOD API or SDK to specify multiple HTTP callback URLs. This feature can be used when you want to send event notifications of a specific type to multiple servers for further processing or send callback messages to multiple environments such as development, testing, and production. This topic describes how to specify multiple HTTP callback URLs.

Description

ApsaraVideo VOD allows you to configure only one callback method and callback URL for each region. The callback setting takes effect globally. ApsaraVideo VOD provides the UserData parameter that allows you to specify multiple callback URLs for muti-environment services.

Specify a global callback URL

Limits

  • To use UserData to specify callback URLs, you must select HTTP callbacks for global event notifications and specify the events for which you want to configure callbacks. If you use Message Service (MNS) callbacks for global event notifications, the HTTP callback URLs that you specify in UserData do not take effect.

  • If you want to use MNS callbacks, you must go to the Cloud Resource Access Authorization page to authorize ApsaraVideo VOD to access MNS.

Usage notes

ApsaraVideo VOD supports HTTP callbacks and MNS callbacks for global event notifications. ApsaraVideo VOD is available in multiple regions and you can configure only one callback method and one callback URL for each region. This way, when events are triggered, ApsaraVideo VOD sends event notifications based on the callback setting that you specified for the region. You can perform the following operations to trigger the events: upload audio, video, or image files, or submit media processing jobs, such as transcoding jobs and review jobs.

多回调-全局

You can configure global event notifications by using the ApsaraVideo VOD console, SDK, or API. For more information about the procedure and limits, see HTTP callbacks and MNS callbacks.

Specify callback URLs in UserData during upload

Limits

  • You can specify the UserData parameter by using the ApsaraVideo VOD SDK or API. You can specify callback URLs in UserData only for HTTP callbacks.

  • You must configure global HTTP callback settings and specify the events for which you want to configure callbacks. Otherwise, the HTTP callback URLs that you specify in UserData do not take effect.

Usage notes

You can specify callback URLs in UserData for media files that are uploaded to ApsaraVideo VOD by using the server operation SDK or upload SDK. The callback URL that you specified is bound to the media source file. In this case, event notifications are sent to the callback URL when you submit media processing jobs such as transcoding jobs and review jobs for the media file. The events for which callbacks are configured are specified in the global callback settings. If you delete the media resource file, subsequent event notifications are sent to the callback URL that is specified in the global callback settings.

上传指定userdata

For more information about how to use the server operation SDK or upload SDK, see Usage notes and Overview. The following operations are supported for uploading media files:

Specify callback URLs in UserData during media processing

Limits

  • You can specify the UserData parameter by using the ApsaraVideo VOD SDK or API. You can specify callback URLs in UserData only for HTTP callbacks.

  • You must configure global HTTP callback settings and specify the events for which you want to configure callbacks. Otherwise, the HTTP callback URLs that you specify in UserData do not take effect.

Usage notes

You can specify callback URLs in UserData when you submit media processing jobs such as transcoding jobs by using the ApsaraVideo VOD SDK or API. You can call the following API operations to submit media processing jobs: SubmitTranscodeJobs, SubmitSnapshotJob, SubmitAIMediaAuditJob, and ProduceEditingProjectVideo.

The callback URL that you specify in UserData during media processing takes effect only for a single event. If you do not specify callback URLs during media processing, the callback URLs that you specified in UserData during upload are preferentially used before the callback URLs specified in the global callback settings are used.

多回调-媒体处理

Sample code

For more information about the structure and details of the UserData parameter, see Request parameters. The following sample code provides an example on the structure of UserData:

{
    "Extend":{
        "width":1280,
        "id":"028a8e56b*****1ebf6bb7afc74",
        "height":720
    },
    "AccelerateConfig":{
        "Type":"oss",
        "Domain":"https://oss-accelerate.aliyuncs.com"
    },
    "MessageCallback":{
        "CallbackURL":"https://xxxxx.com/2016-08-15/proxy/httpcallback/testcallback/",
        "CallbackType":"http"
    }
}

The following sample code provides an example on how to build UserData:

public static String buildUserData() {

        JSONObject userData = new JSONObject();
        // Configure message callbacks.
        JSONObject messageCallback = new JSONObject();
        messageCallback.put("CallbackType", "http");
        messageCallback.put("CallbackURL", "https://xxxxx.com/2016-08-15/proxy/httpcallback/testcallback/");
        userData.put("MessageCallback", messageCallback);

        // The fields that you want to pass to UserData. You can pass custom parameters.
        JSONObject extend = new JSONObject();
        extend.put("id", "028a8e56b*****1ebf6bb7afc74");
        extend.put("width", 1280);
        extend.put("height", 720);
        userData.put("Extend", extend);

        // Configure upload acceleration if the acceleration service is needed. Before you can use upload acceleration, apply to enable the acceleration feature.
        JSONObject accelerateConfig = new JSONObject();
        accelerateConfig.put("Type", "oss");
        accelerateConfig.put("Domain", "https://oss-accelerate.aliyuncs.com");
        userData.put("AccelerateConfig", accelerateConfig);

        return userData.toJSONString();
    }

References