使用阿里云提供的SDK获取视频上传凭证,已经引用es6-promise,在IE浏览器向阿里云提供的接口发送上传凭证,返回签名错误。
错误码:SignatureDoesNotMatch
错误信息:The request signature we calculated does not match the signature you provided. Check your key and signing method
其他使用IE内核的浏览器也会出现此错误。
检查accesskey显示正常,其他非IE内核浏览器可以正常上传视频
相关js代码:
var uploader = new AliyunUpload.Vod({
//分片大小默认1M,不能小于100K
partSize: 1024 * 1024,
//并行上传分片个数,默认5
parallel: 5,
//网络原因失败时,重新上传次数,默认为3
retryCount: 100,
//网络原因失败时,重新上传间隔时间,默认为2秒
retryDuration: 2,
// 开始上传
'onUploadstarted': function (uploadInfo) {
console.log("onUploadStarted:" + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object);
//上传方式1, 需要根据uploadInfo.videoId是否有值,调用点播的不同接口获取uploadauth和uploadAddress,如果videoId有值,调用刷新视频上传凭证接口,否则调用创建视频上传凭证接口
upload_auth = get_video_upload_auth(uploadInfo.file.name);
uploader.setUploadAuthAndAddress(uploadInfo, upload_auth.UploadAuth, upload_auth.UploadAddress, upload_auth.VideoId);
$('#video_id').attr('videoname', uploadInfo.file.name);
},
// 文件上传成功
'onUploadSucceed': function (uploadInfo) {
console.log("onUploadSucceed: " + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object);
console.log(upload_auth.VideoId);
$("#video_id").val(upload_auth.VideoId);
$(".upload-warning").html('上传完成');
$("#videoUPload").attr("disabled", false);
$(".cancel-upload").css('display', 'none');
},
// 文件上传失败
'onUploadFailed': function (uploadInfo, code, message) {
console.log("onUploadFailed: file:" + uploadInfo.file.name + ",code:" + code + ", message:" + message);
$(".upload-warning").html('视频上传失败,请重新上传');
$("#videoUPload").attr("disabled", false);
},
// 文件上传进度,单位:字节
'onUploadProgress': function (uploadInfo, totalSize, loadedPercent) {
$(".progress-warp").css('display', 'inline-block');
$(".cancel-upload").css('display', 'inline-block');
var progress_width = Math.ceil(loadedPercent * 100) > 20 ? Math.ceil(loadedPercent * 100) : 20;
$(".progress-warp .progress").css('width', progress_width + "%");
$(".progress-warp .progress").html(Math.ceil(loadedPercent * 100) + "%");
var warnText = loadedPercent != 1 ? '上传中' : '上传完成';
$(".upload-warning").html(warnText);
},
// 上传凭证超时
'onUploadTokenExpired': function (uploadInfo) {
console.log("onUploadTokenExpired");
//上传方式1 实现时,根据uploadInfo.videoId调用刷新视频上传凭证接口重新获取UploadAuth
upload_auth = get_new_upload_auth(upload_auth.VideoId);
console.log(upload_auth);
uploader.resumeUploadWithAuth(upload_auth.UploadAuth);
},
//全部文件上传结束
'onUploadEnd': function (uploadInfo) {
console.log("onUploadEnd: uploaded all the files");
}
});
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。