分片上传(类似视频比较大的时候)

![QQ图片20201118164813.png](https://upload-images.jianshu.io/upload_images/18145958-c018278e815f3190.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240

getTecInfoOss({}).then(res=>{
                    let OSS = require('ali-oss');
                    let client = new OSS(res.data);
                    let checkpoint;
                    let index =file.name.lastIndexOf(".");
                    let str=file.name.substring(index);
                    var name=(new Date().getTime())+str;
                    async function resumeUpload() {
                        const result = await client.multipartUpload(name, file, {
                            checkpoint,
                            async progress(percentage, cpt) {
                                checkpoint = cpt;
                                that.used=parseInt(percentage*100);
                            },
                        });
                        if(result){
                            that.ruleForm.videoUrl='http://tec-info.oss-cn-beijing.aliyuncs.com/'+result.name;
                            var params={
                                objId:that.ruleForm.id,
                                objType:'tecCourseVideo',
                                url:that.ruleForm.videoUrl,
                                fileName:result.name,
                            };
                            addAttachment(params).then(res=>{
                                if (res.code == 200) {
                                    that.ruleForm.videoUrl='http://tec-info.oss-cn-beijing.aliyuncs.com/'+result.name;
                                    that.$message.success("上传视频成功");
                                }
                            })
                        }

                    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容