oss分片上传视频或者图片

var oss_result;
      // 获取oss配置
      await this.$axios.modelAdmin
        .oss_conf()
        .then(res => {
          oss_result = res.data;
        });
      // oss配置
      var oss_obj = oss_result;
      let client = new OSS.Wrapper({
        secure: true,
        region: "oss-cn-beijing", //你的oss地址 ,具体位置见下图
        accessKeyId: oss_obj.token.AccessKeyId, //你的ak
        accessKeySecret: oss_obj.token.AccessKeySecret, //你的secret
        stsToken: oss_obj.token.SecurityToken,
        bucket: "graphic-module" //ossbucket//edu-pigeonhole
      });
      //上传到oss的地址
      var store = "Graphic_module/" + "25855" + "/" + this.file.name;

      var str = this.form.videocontent;
      //需要向服务器传的base64
      // var file_rea = new OSS.Buffer(
      //   str.replace(/^data:\w+\/\w+;base64,/, ""),
      //   "base64"
      // );
      var that = this;
      const file_result = await client.multipartUpload(store, this.file, {
        partSize: 10485760,
        parallel: 50,
        headers: {
          // "Content-MD5":
        },
        progress: async function(p, checkpoint) {
          console.log(p);
          console.log(checkpoint);

          // 断点记录点。 浏览器重启后无法直接继续上传,需用户手动触发进行设置。
          that.percentageWidth = parseInt(p * 100);
        }
      });

 

你可能感兴趣的:(vue)