开发者社区> 问答> 正文

IE浏览器上传视频到阿里云失败

xmulab 2018-12-05 17:56:00 777

使用阿里云提供的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");
    }
});
前端开发 JavaScript 开发工具
分享到
取消 提交回答
全部回答(1)

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

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