开发者社区> 问答> 正文

上传视频点播的时候前端出错,报错在sdk-upload包里

< html >

< head >
< script src = "./lib/es6-promise.min.js" > < / script >
< script src = "./lib/aliyun-oss-sdk-5.3.1.min.js" > < / script >
< script src = "aliyun-upload-sdk-1.5.0.min.js" > < / script >
</ head >

< body >
< form action = "" >
< input type = "file" name = "file" id = "files" accept = "video/mp4,video/mov" multiple = "" />
</ form >

< script >
var uploader = new AliyunUpload . Vod ({
//阿里账号ID,必须有值 ,值的来源https://help.aliyun.com/knowledge_detail/37196.html
userId: "1720442442383302" ,
//上传到点播的地域, 默认值为'cn-shanghai',//eu-central-1,ap-southeast-1
region: "cn-shanghai" ,
//分片大小默认1M,不能小于100K
partSize: 1048576 ,
//并行上传分片个数,默认5
parallel: 5 ,
//网络原因失败时,重新上传次数,默认为3
retryCount: 3 ,
//网络原因失败时,重新上传间隔时间,默认为2秒
retryDuration: 2 ,
// 开始上传
'onUploadstarted' : function ( uploadInfo ) {
console . log ( "onUploadStarted:" + uploadInfo . file . name + ", endpoint:" + uploadInfo . endpoint +
", bucket:" + uploadInfo . bucket + ", object:" + uploadInfo . object );
//获取STS Token,设置到SDK
uploader . setSTSToken ( uploadInfo , accessKeyId , accessKeySecret , secretToken );
},
// 文件上传成功
'onUploadSucceed' : function ( uploadInfo ) {
console . log ( "onUploadSucceed: " + uploadInfo . file . name + ", endpoint:" + uploadInfo . endpoint +
", bucket:" + uploadInfo . bucket + ", object:" + uploadInfo . object );
},
// 文件上传失败
'onUploadFailed' : function ( uploadInfo , code , message ) {
console . log ( "onUploadFailed: file:" + uploadInfo . file . name + ",code:" + code + ", message:" +
message );
},
// 文件上传进度,单位:字节
'onUploadProgress' : function ( uploadInfo , totalSize , loadedPercent ) {
console . log ( "onUploadProgress:file:" + uploadInfo . file . name + ", fileSize:" + totalSize +
", percent:" + Math . ceil ( loadedPercent * 100 ) + "%" );
},
// 上传凭证超时
'onUploadTokenExpired' : function ( uploadInfo ) {
console . log ( "onUploadTokenExpired" );
//重新获取STS token,恢复上传
uploader . resumeUploadWithSTSToken ( accessKeyId , accessKeySecret , secretToken );
},
//全部文件上传结束
'onUploadEnd' : function ( uploadInfo ) {
console . log ( "onUploadEnd: uploaded all the files" );
}
});

var userData = {
"Vod" : {
"Title" : "test" ,
"CateId" : "234"
}
};
document . getElementById ( "files" ). addEventListener ( 'change' , function ( event ) {
for ( var i = 0 ; i < event . target . files . length ; i ++) {
// 逻辑代码
uploader . addFile ( event . target . files [ i ], null , null , null , userData );
}
uploader . startUpload ();
});
< / script >
</ body >

</ html >


展开
收起
1720442442383302 2019-03-18 14:42:43 2820 0
1 条回答
写回答
取消 提交回答
  • 阿里云ping https://ping.gaomeluo.com/aliyun/
    你的这个情况,可能需要提交工单,咨询一下阿里云官方工程师如何处理:    提交工单教程  
    这里是知道平台,不是工单平台
    如果本条回复帮助你解决了问题,请“采纳”,谢谢
    2019-03-18 14:48:09
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Vue.js 在前端服务化上的探索与实践 立即下载
阿里文娱大前端技术实践 立即下载
前端代码是怎样智能生成的 立即下载