开发者社区> 问答> 正文

视频点播上传使用node.js SDk进行上传在获取上传凭证及地址时报错

zhangyoof 2019-01-22 19:08:12 651

var RPCClient = require('@alicloud/pop-core').RPCClient;
//初始化客户端
function initVodClient(accessKeyId, secretAccessKey,) {

var regionId = 'cn-shanghai';   // 点播服务接入区域
var client = new RPCClient({
    accessKeyId: accessKeyId,
    secretAccessKey: secretAccessKey,
    endpoint: 'http://vod.' + regionId + '.aliyuncs.com',
    apiVersion: '2017-03-21'
});
return client;

}

//获取视频上传地址和凭证
export function creatUploadInfo (AccessKeyId,AccessKeySecret){

debugger
var client = initVodClient(AccessKeyId,AccessKeySecret);
debugger
client.request("CreateUploadVideo", {
    Title: 'this is a sample',
    FileName: 'filename.mp4'
}, {}).then(function (response) {console.log("success=====>>>>>",response)
    console.log('VideoId = ' + response.VideoId);
    console.log('UploadAddress = ' + response.UploadAddress);
    console.log('UploadAuth = ' + response.UploadAuth);
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
   console.log("err====>>>",response)
   // console.log('ErrorCode = ' + response.data.Code);
   // console.log('ErrorMessage = ' + response.data.Message);
   // console.log('RequestId = ' + response.data.RequestId);
});

}
调用creatUploadInfo 方法时控制台抛出错误如下:
TypeError: Cannot read property '_headers' of undefined at httpx.request.then (rpc.js:181)

JavaScript 开发工具
分享到
取消 提交回答
全部回答(4)
添加回答

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程