本文提供了Node.js SDK新增视频文件到媒体库并触发工作流执行的完整代码示例。

示例代码

新增视频文件到媒体库,可以指定工作流ID触发工作流处理视频文件。
var RPCClient = require('@alicloud/pop-core').RPCClient;

function initMtsClient(accessKeyId, accessKeySecret, regionId) {
    var client = new RPCClient({
        accessKeyId: accessKeyId,
        accessKeySecret: accessKeySecret,
        endpoint: 'http://mts.' + regionId + '.aliyuncs.com',
        apiVersion: '2014-06-18'
    });
    return client;
}

//Step 1 .set region:cn-hangzhou、cn-shenzhen、cn-shanghai、cn-beijing
var REGION = "xxx";
var OSS_REGION = "xxx";
var mtsEndpoint = "mts." + REGION + ".aliyuncs.com";

//Step 2.set accesskey & keySecret
var accessKeyId = "xxx";
var accessKeySecret = "xxx";

client = initMtsClient(accessKeyId, accessKeySecret, REGION)

client.request('AddMedia', {
    FileURL: 'xxx'//比如http://ice-auto-test-bj.oss-cn-beijing.aliyuncs.com/result.mp4

}, {}).then(function (response) {
    console.log(JSON.stringify(response));
}).catch(function (response) {
    console.log(response.requestId);
    console.log(response.Code);
});